本文整理汇总了C#中Texture.GenerateMipSubLevels方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.GenerateMipSubLevels方法的具体用法?C# Texture.GenerateMipSubLevels怎么用?C# Texture.GenerateMipSubLevels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture.GenerateMipSubLevels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnReset
/// <summary>
/// Device has been reset - rebuild unmanaged resources
/// </summary>
public static void OnReset()
{
Debug.WriteLine("SkyBox.OnReset()");
texture = TextureLoader.FromFile(Engine.Device, FileResource.Fsp("textures", "Sky.png"));
texture.GenerateMipSubLevels();
}
示例2: OnReset
public void OnReset(object sender, EventArgs e)
{
Debug.WriteLine("Terrain.Reset()");
/// TODO: Load the whole library of textures!
texture = TextureLoader.FromFile(Engine.Device,FileResource.Fsp("ground.bmp"));
texture.GenerateMipSubLevels();
}
示例3: CreateTexture
/// <summary>
/// The create texture.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="bitmap">The bitmap.</param>
/// <returns></returns>
/// <remarks></remarks>
public static Texture CreateTexture(ref Device device, Bitmap bitmap)
{
if (bitmap == null)
{
return null;
}
Texture texture = new Texture(
device, bitmap.Width, bitmap.Height, 1, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
BitmapData bitmapData = bitmap.LockBits(
new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
int pitch;
GraphicsStream textureData = texture.LockRectangle(0, LockFlags.None, out pitch);
// Debug.Assert(bitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Debug.Assert(sizeof(int) == 4 && (bitmapData.Stride & 3) == 0 && (pitch & 3) == 0);
unsafe
{
int* texturePointer = (int*)textureData.InternalDataPointer;
for (int y = 0; y < bitmap.Height; y++)
{
int* bitmapLinePointer = (int*)bitmapData.Scan0 + y * (bitmapData.Stride / sizeof(int));
int* textureLinePointer = texturePointer + y * (pitch / sizeof(int));
int length = bitmap.Width;
while (--length >= 0)
{
*textureLinePointer++ = *bitmapLinePointer++;
}
}
}
bitmap.UnlockBits(bitmapData);
texture.UnlockRectangle(0);
texture.GenerateMipSubLevels();
texture.AutoGenerateFilterType = TextureFilter.Linear;
return texture;
}
示例4: CopyToTexture
public static void CopyToTexture(OpsContext context, Texture newTexture, string srcArg, Filter filter)
{
if(srcArg == null || srcArg.Length == 0)
return;
OpsTexture src = context.GetTexture(srcArg);
if(src == null)
throw new OpsException("Could not find source texture: "+srcArg );
if(!(src.Texture is Texture))
throw new OpsException("Source texture is not a texture2D: "+srcArg);
Texture srcTex = src.Texture as Texture;
SurfaceLoader.FromSurface(newTexture.GetSurfaceLevel(0), srcTex.GetSurfaceLevel(0), filter| (src.SRGB?Filter.SrgbIn:0), 0);
newTexture.GenerateMipSubLevels();
}