From 593410df6f11070983dd2f13284e3b43a560f54c Mon Sep 17 00:00:00 2001 From: Luciano Ciccariello Date: Wed, 12 Jun 2019 04:21:10 +0300 Subject: [PATCH] Load textures in the correct channel order --- OpenKh.Game/MonoDrawing.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OpenKh.Game/MonoDrawing.cs b/OpenKh.Game/MonoDrawing.cs index 30a124ac0..ea7c274d9 100644 --- a/OpenKh.Game/MonoDrawing.cs +++ b/OpenKh.Game/MonoDrawing.cs @@ -55,7 +55,16 @@ public void Clear(Color color) public ISurface CreateSurface(int width, int height, PixelFormat pixelFormat, SurfaceType type = SurfaceType.Input, DataResource dataResource = null) { var texture = new Texture2D(GraphicsDevice, width, height); - texture.SetData(dataResource.Data); + var data = new byte[dataResource.Data.Length]; + for (int i = 0; i < data.Length; i+=4) + { + data[i + 2] = dataResource.Data[i + 0]; + data[i + 1] = dataResource.Data[i + 1]; + data[i + 0] = dataResource.Data[i + 2]; + data[i + 3] = dataResource.Data[i + 3]; + } + + texture.SetData(data); return new CSurface(texture); }