The VertexPositionTexture
requires a .TextureCoordinate
aswell.
(where 0f being the start, 1f being the end.)
The solution is just:
// VertexPositionTexture
// ( Vector2 position (on screen UVViewport coordscoordinate [-1.0~10->1.0]),
// Vector2 texturePosition (on texture UVTexture coordscoordinate [0.0~10->1.0])
VertexPositionTexture[] vertices = new VertexPositionTexture[4];VertexPositionTexture[4]
{
new VertexPositionTexture(pointA, new Vector2(0f, 1f)),
new VertexPositionTexture(pointB, new Vector2(0f, 0f)),
new VertexPositionTexture(pointC, new Vector2(1f, 1f)),
new VertexPositionTexture(pointD, new Vector2(1f, 0f)),
};
and replace the DrawUserIndexedPrimitives
with
GraphicsDevice.DrawUserIndexedPrimitives(
PrimitiveType.TriangleList, // drawing 2Specify trianglestri-based forquad aassembly
square so using trianglelist
vertices, // theYour input verticiesvertices
0, // verticesOffset offsetin vertex array (0 for noneno offset)
4, // vertexLength countof (4the forinput fourvertices points)array
new[] { 0, 1, 2, 1, 2, 3 }, // the indicesIndicies (a tri with index (0, 1, 2), and (1, 2, 3))
0, // indiciesOffset offsetin index array (0 for none)
2 // numberNumber of tris to draw (2 for a square)
);
(turns out Note that MonoGame's DrawUserIndexedPrimitives
's indices arethe input vertex array is order-sensitive. weird and you might get wrongly assembled quads if the order isn't correct.)