本文整理汇总了C#中Texture.Upload方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.Upload方法的具体用法?C# Texture.Upload怎么用?C# Texture.Upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture.Upload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitGL
// =====================================================================
// Updating
// =====================================================================
// =====================================================================
// Shortcuts
// =====================================================================
// =====================================================================
// Overrides
// =====================================================================
// =====================================================================
// Private functions
// =====================================================================
private void InitGL()
{
GL.ClearColor(GlobalSettings.BackgroundColor);
GL.Enable(EnableCap.Texture2D);
GL.ShadeModel(ShadingModel.Smooth); // Enable Smooth Shading
GL.Enable(EnableCap.DepthTest); // Enables Depth Testing
GL.DepthFunc(DepthFunction.Lequal); // The Type Of Depth Testing To Do
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); // Really Nice Perspective Calculations
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate);
_toolboxUpNormal = new TextureGL(Resources.buttong);
_toolboxUpHover = new TextureGL(Resources.buttong_2);
_toolboxDownNormal = new TextureGL(Resources.buttong_down);
_toolboxDownHover = new TextureGL(Resources.buttong_down2);
_cubeSides = new TextureGL(Resources.cube_sides);
_cubeSides.SetMipmapping(true);
_cubeSides.SetRepeat(true);
_font = new TextureGL(Resources.tinyfont);
_font.SetMipmapping(false);
_font.SetRepeat(false);
_grassTop = new TextureGL(GlobalSettings.GetDataURI("grass.png"));
_grassTop.SetMipmapping(false);
_grassTop.SetRepeat(true);
_dynamicOverlay = new BackgroundImage("Dynamic", "Dynamic", null);
_dynamicOverlay.Item = mDYNAMICOVERLAYToolStripMenuItem;
_backgrounds.Add(_dynamicOverlay);
foreach (string file in Directory.GetFiles(GlobalSettings.GetDataURI("Overlays"), "*.png"))
{
try
{
var image = new TextureGL(file);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp);
_backgrounds.Add(new BackgroundImage(file, Path.GetFileNameWithoutExtension(file), image));
}
catch
{
MessageBox.Show(this, string.Format(GetLanguageString("B_MSG_OVERLAYERROR"), file));
}
}
int index = 0;
foreach (BackgroundImage b in _backgrounds)
{
ToolStripMenuItem item = b.Item ?? new ToolStripMenuItem(b.Name);
b.Item = item;
if (b.Path == GlobalSettings.LastBackground)
{
item.Checked = true;
_selectedBackground = index;
}
item.Click += item_Clicked;
item.Tag = index++;
if (!backgroundsToolStripMenuItem.DropDownItems.Contains(item))
backgroundsToolStripMenuItem.DropDownItems.Add(item);
}
_previewPaint = new TextureGL();
GlobalDirtiness.CurrentSkin = new TextureGL();
_alphaTex = new TextureGL();
var arra = new byte[64 * 32];
_previewPaint.Upload(arra, 64, 32);
_previewPaint.SetMipmapping(false);
_previewPaint.SetRepeat(false);
GlobalDirtiness.CurrentSkin.Upload(arra, 64, 32);
GlobalDirtiness.CurrentSkin.SetMipmapping(false);
GlobalDirtiness.CurrentSkin.SetRepeat(false);
arra = new byte[]
{
127,
127,
127,
//.........这里部分代码省略.........
示例2: RandomizeParticles
private void RandomizeParticles(Texture destination, Texture VelocityDestination)
{
float[] data = new float[this.ParticleTexWidth * this.ParticleTexHeight * 4];
float[] datav = new float[this.ParticleTexWidth * this.ParticleTexHeight * 4];
var r = new Random();
for (int i = 0; i < this.ParticleTexWidth * this.ParticleTexHeight; i++)
{
data[i * 4 + 0] = (float)r.NextDouble(); // x
data[i * 4 + 1] = (float)r.NextDouble(); // y
data[i * 4 + 2] = 0f; // height
data[i * 4 + 3] = 0f; // carrying
// velocity
datav[i * 4 + 0] = 0f; // x
datav[i * 4 + 1] = 0f; // y
datav[i * 4 + 2] = 0f; // height (maybe)
datav[i * 4 + 3] = 0f; // carrying
}
destination.Upload(data);
VelocityDestination.Upload(datav);
}
示例3: RandomizeParticles
private void RandomizeParticles(Texture destination)
{
float[] data = new float[this.ParticleTexWidth * this.ParticleTexHeight * 4];
var r = new Random();
for (int i = 0; i < this.ParticleTexWidth * this.ParticleTexHeight; i++)
{
data[i * 4 + 0] = (float)r.NextDouble(); // x
data[i * 4 + 1] = (float)r.NextDouble(); // y
data[i * 4 + 2] = 0f; // carrying nothing
data[i * 4 + 3] = 0.001f; // particle water mass
}
destination.Upload(data);
}
示例4: GenerateFloatTexture
public Texture GenerateFloatTexture()
{
this.TextureInternalFormat = PixelInternalFormat.R32f;
this.TexturePixelFormat = PixelFormat.Red;
this.TexturePixelType = PixelType.Float;
var t = new Texture(this.Width, this.Height, this.Target, this.TextureInternalFormat, this.TexturePixelFormat, this.TexturePixelType);
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat));
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat));
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear));
t.SetParameter(new TextureParameterInt(TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear));
// allocate space for texture
var data = new float[this.Width * this.Height];
var rand = new Random();
float rx = (float)rand.NextDouble();
float ry = (float)rand.NextDouble();
// generate some noise
ParallelHelper.For2D(this.Width, this.Height, (x, y, i) =>
{
data[i] = SimplexNoise.wrapfbm(
(float)x, (float)y,
(float)this.Width, (float)this.Height,
rx, ry,
10, // octaves
0.005f, // scale
2.0f, // amplitude
h => Math.Abs(h),
h => h);
});
//data.Normalize();
float xmin = data.Min();
float xmax = data.Max();
float scale = xmax - xmin;
if (scale != 0.0f)
{
scale = 1.0f / scale;
}
else
{
scale = 1.0f;
}
ParallelHelper.For2D(this.Width, this.Height, (i) =>
{
data[i] = (data[i] - xmin) * scale;
});
t.Upload(data);
return t;
}