Jump to content
  • Advertisement
Sign in to follow this  
Cygon

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

This topic is 4290 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!