Hello all. I have been converting one of the XNA samples to MonoGame. After modifying many of the fx files, I have finally got it to build. However, when I run it, it gets to a spot in the code where I get a System.InvalidOperationException. The message says “The vertex stride is larger than the vertex buffer.”
The two lines of code that do this work are:
vertexBuffer = new VertexBuffer(
BaseGame.Device,
typeof(TangentVertex),
vertices.Length,
BufferUsage.WriteOnly);
vertexBuffer.SetData(vertices);
The exception occurs at the vertexBuffer.SetData() call. As you can see, however, there should be no issue as the VertexBuffer is created with the number of vertices required (66049 to be precise).
Vertices is declared as
TangentVertex[] vertices = new TangentVertex[GridWidth * GridHeight];
GridWidth = GridHeight = 257, so GridWidth*GridHeight = 66049 as it is supposed to.
I am using the HiDef profile in a Windows DirectX project. Any ideas?