I'm using SharpDX Toolkit and load a png file with SharpDX.Toolkit.Graphics.Texture.Load(GraphicsDevice, Stream)
If I apply the texture to another texture it's drawn upside down.
The texture is:
and is drawn as this:
Loading is:
Texture image;
FileInfo file = new FileInfo(layer.Id.ToString() + ".png");
if (!file.Exists)
return;
image = Texture.Load(GraphicsDevice, file.OpenRead());
layer.SetData(image.GetData<byte>());
the SetData Method:
private Texture2D map;
public void SetData(byte[] data) {
map.SetData(data);
}
VertexBuffer declaration:
vertexBuffer = SharpDX.Toolkit.Graphics.Buffer.Vertex.New<VertexPositionTexture>(GraphicsDevice, new[] {
new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0, 0)),
new VertexPositionTexture(new Vector3(0, Size.Height, 0), new Vector2(0, 1)),
new VertexPositionTexture(new Vector3(Size.Width, Size.Height, 0), new Vector2(1, 1)),
new VertexPositionTexture(new Vector3(Size.Width, 0, 0), new Vector2(1, 0))
});
and the WVP:
wvp = Matrix.Scaling(zoom) *
Matrix.LookAtLH(new Vector3(camPosition, 0), new Vector3(camPosition, 1), Vector3.Up) *
Matrix.OrthoLH(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1);
Any idea why SharpDX draws the image upside down and how I can fix it?