Skip to content

Commit

Permalink
Load textures in the correct channel order
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo committed May 23, 2020
1 parent 3852e4e commit 593410d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion OpenKh.Game/MonoDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 593410d

Please sign in to comment.