directxdirect3dmanaged-directx

Managed Direct3D: Lock entire Vertex Buffer


I have a Mesh object returned from Mesh::TextFromFont and I am trying to set the color of each vertex. I am calling the vertex buffer's Lock function like this:

mesh->VertexBuffer->Lock(0, LockFlags::None);

However, this call throws an exception. Another overload of Lock seems to work fine, however it requires me to pass the rank of the returned vertex array. What is the solution here? How do I lock the vertex buffer of a mesh returned from TextFromFont?


Solution

  • The answer might probably lie here:

    When using this method to retrieve an array from a resource that was not created with a type, always use the overload that accepts a type.

    In true MSDN fashion, there is no further explanation.