本文整理汇总了C#中GraphicsDevice.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.Copy方法的具体用法?C# GraphicsDevice.Copy怎么用?C# GraphicsDevice.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice.Copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDds
static void CreateDds(GraphicsDevice device, TileSetLoader loader, string dstPath)
{
int numDistinctBitmaps = EnumHelpers.GetEnumMax<SymbolID>() + 1;
const int bytesPerPixel = 4;
int maxTileSize = 64;
int mipLevels = 6; // 64, 32, 16, 8, 4, 2
var atlasTexture = Texture2D.New(device, maxTileSize, maxTileSize, mipLevels,
SharpDX.Toolkit.Graphics.PixelFormat.B8G8R8A8.UNorm, TextureFlags.None, numDistinctBitmaps,
D3D11.ResourceUsage.Default);
//int autoGenMipLevel = 0;
for (int mipLevel = 0; mipLevel < mipLevels; ++mipLevel)
{
int tileSize = maxTileSize >> mipLevel;
/*
if (tileSet.HasTileSize(tileSize) == false)
{
autoGenMipLevel = mipLevel - 1;
break;
}
*/
// leave the first one (Undefined) empty
for (int i = 1; i < numDistinctBitmaps; ++i)
{
var bmp = loader.GetTileBitmap((SymbolID)i, tileSize);
int pitch = tileSize * bytesPerPixel;
var arr = new uint[tileSize * tileSize];
bmp.CopyPixels(arr, pitch, 0);
using (var txt = Texture2D.New(device, tileSize, tileSize, SharpDX.Toolkit.Graphics.PixelFormat.B8G8R8A8.UNorm, arr))
device.Copy(txt, 0, atlasTexture, atlasTexture.GetSubResourceIndex(i, mipLevel));
}
}
// Generate mipmaps for the smallest tiles
//atlasTexture.FilterTexture(device.ImmediateContext, autoGenMipLevel, FilterFlags.Triangle);
string path = Path.Combine(dstPath, "TileSet.dds");
atlasTexture.Save(path, ImageFileType.Dds);
Console.WriteLine("Generated TileSet to {0}", path);
}