Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


index buffers

This topic is 5776 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

I need a little help with index buffers. Im writing a terrain engine, and so far I loaded all the vertices of my terrain into a vertex buffer, and then I load the offsets of the vertices into the index buffer. My question is, is there any specific order that the verticies need to go into the vertex buffer? As of now i get nothing when I render from the index buffer. thanks, Ben

Share this post

Link to post
Share on other sites
There is no specific order in which you have to put vertices in the vertex buffer but...

There IS a specific order in which you have to use them. How you use them is determined by the index buffer.

The clockwise rule applies to how your vertices are referenced and used by the indices.

If your vertices are declared like this:
{0, 1, 2, 3, 4, 5, 6, 7}

in this order to result in these positions:


then your index buffer should contain something like:
{0, 1, 4, 4, 1, 5, 1, 2, 5, 5, 2, 6, 2, 3, 6, 6, 3, 7}
in order to call DrawIndexedPrimitive() with the triangle list specification.

DX will try to render triangles using the clockwise order so it will go to vertex 0, 1 and 4 for the first triangle, then to vertex 4, 1 and 5 for the next one and so on.

You can generate your vertex and index values based on your map width in # of tiles or vertices or whatever. There is a mathematical progression (a pattern) that you can code to.

Share this post

Link to post
Share on other sites

  • 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!