/// <summary> /// Create a buffer containing all GameColors /// </summary> public void CreateGameColorBuffer() { var arr = new int[GameColorRGB.NUMCOLORS]; for (int i = 0; i < arr.Length; ++i) { var gc = (GameColor)i; var rgb = GameColorRGB.FromGameColor(gc); arr[i] = rgb.R | (rgb.G << 8) | (rgb.B << 16); } var buf = ToDispose(Buffer <int> .New(this.GraphicsDevice, arr, BufferFlags.ShaderResource, SharpDX.DXGI.Format.R8G8B8A8_UNorm, SharpDX.Direct3D11.ResourceUsage.Immutable)); this.Parameters["g_colorBuffer"].SetResource(buf); }
void CreateTint() { var tintBmp = new WriteableBitmap(256, 256, 96, 96, PixelFormats.Bgr32, null); var w = tintBmp.PixelWidth; var h = tintBmp.PixelHeight; var gameColorArr = (GameColor[])Enum.GetValues(typeof(GameColor)); var colorArr = new GameColorRGB[gameColorArr.Length - 1]; for (int i = 0; i < gameColorArr.Length - 1; ++i) { colorArr[i] = GameColorRGB.FromGameColor(gameColorArr[i]); } var arr = new int[h, w]; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { var idx = (y / 16) * (w / 16) + (x / 16); if (idx >= colorArr.Length) { continue; } arr[y, x] = colorArr[idx].ToInt32(); } } tintBmp.WritePixels(new Int32Rect(0, 0, w, h), arr, w * 4, 0); m_tint = arr; tintImage.Source = tintBmp; }