new GraphicsBuffer problems

Hello I am using VS2005 and MDX December 2005. Suppose that I have this code to generate a mesh of a square:

mesh = new Mesh(device, 2, 4, MeshFlags.Managed, PositionNormalTextured.Format);

GraphicsBuffer<PositionNormalTextured> vertBuffer = mesh.LockVertexBuffer<PositionNormalTextured>(LockFlags.None);
int i = 0;
PositionNormalTextured[] verts = new PositionNormalTextured[4];
verts[i++] = new PositionNormalTextured(0, 0, 0, 0, 0, 1, 0, 0);
verts[i++] = new PositionNormalTextured(1, 0, 0, 0, 0, 1, 1, 0);
verts[i++] = new PositionNormalTextured(0, 1, 0, 0, 0, 1, 0, 1);
verts[i++] = new PositionNormalTextured(1, 1, 0, 0, 0, 1, 1, 1);

vertBuffer.Write(verts);
mesh.UnlockVertexBuffer();

A similar version of this code worked just fine in previous versions of MDX. But now when i check vertBuffer.NumberElements it always returns 0 (for any mesh not just this one). Though mesh.NumberVertices does return a correct number.

Later I need to modify this mesh:

vertBuffer = mesh.LockVertexBuffer<PositionNormalTextured>(LockFlags.None);
verts = vertBuffer.ReadArray(mesh.NumberVertices);
vertBuffer.Write(verts);
mesh.UnlockVertexBuffer();

But I get a security exception. Am I doing something wrong or its a bug



Answer this question

new GraphicsBuffer problems