#### Archived

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.

## 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 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:
0--1--2--3

4--5--6--7

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.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 12
• 16
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633357
• Total Posts
3011503
• ### Who's Online (See full list)

There are no registered users currently online

×