Sign in to follow this  
Cygon

[.net] XNA: DrawIndexedPrimitives() vs. DrawUserIndexedPrimitives()

Recommended Posts

Hi! I've got an annoying little problem in my XNA application. DrawUserIndexedPrimitive() correctly draws my model onto the screen, but DrawIndexedPrimitve() doesn't (there's absolutely nothing on the screen) Just so you see this is not your usual noob that didn't understand the concept of vertex & index buffers, compare these two snippets. Doesn't work:
this.graphicsDevice.DrawIndexedPrimitives(
  PrimitiveType.TriangleList,
  0, // baseVertex
  0, // minVertexIndex
  this.walls.GeneratedVertices.Count, // numVertices
  0, // startIndex
  this.walls.GeneratedIndices.Count / 3 // primitiveCount
);

Does work:
VertexPositionColorTexture[] tmpVertices = new VertexPositionColorTexture[
  this.walls.GeneratedVertices.Count
];
this.graphicsDevice.Vertices[0].VertexBuffer.GetData<
  VertexPositionColorTexture
>(tmpVertices);

short[] tmpIndices = new short[this.walls.GeneratedIndices.Count];
this.graphicsDevice.Indices.GetData<short>(tmpIndices);
      
this.graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColorTexture>(
  PrimitiveType.TriangleList,
  0,
  this.walls.GeneratedVertices.Count,
  this.walls.GeneratedIndices.Count / 3,
  tmpIndices,
  tmpVertices
);

I'm taking the data I feed to DrawUserIndexedPrimitve() right out of the vertex and index buffers. So the contents of those two buffers are alright and have been assigned to the GraphicsDevice. What could be the problem? -Markus-

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this