Index Buffer?

Started by
13 comments, last by EasyGino 20 years, 6 months ago
How does this "index" buffer differ from the traditional Vertex buffer? I''m looking to create a world like atmosphere and it would be a bit difficult using triangles to create everything I was reading through the DrunkenHyenas online tutorials, but couldn''t find anything that covered that.
Advertisement
Index buffers are used with vertex buffers, so that a single vertex can be used multiple times during single draw call.
It doesn''t, therefore, replace the vertex buffers.

-Nik

Niko Suni

Nik! I expect more from you, where are your diagrams with the smiley faces Where are the examples!? LOL I''m slow, remember? :D
I could explain a whole bunch of info on an index buffer here... but why not just show you the ultimate power of GOOGLE??!!!

I am assuming you are using d3d since you were looking at DrunkenHyenas tuts.

[edited by - curtmax_0 on October 16, 2003 11:46:13 AM]
Why would I use google when we have a forum here? Why would anyone post anything here. You could find everything you ever needed on a search engine. But I come here for the advise and opinions of the individuals on this board, not to hear about people telling me to look elsewhere.
Sorry, I was just pointing out, there are several tuts you can find which probably explain it well( with diagrams and all ), if you just search for them.
Hi,

I couldn''t draw a diagram on this subject
However, i give an example.

Consider 4 vertices, numbered 0, 1, 2 and 3.
The vertice''s positions are assumed to be in clockwise order.

Now, how would you draw a quad (list of 2 triangles), with this data, without duplicating the actual vertices?

Answer: Make a index buffer the size of 6 indices.
The first triangle''s indices are 0, 1 and 2.
Second triangle''s indices are 0, 2 and 3.

Now, the vertices 0 and 2 get to be used twice in the same draw call. Because indices take much less space than vertices, this is a memory advantage.

Other, non-obvious effect of the indexing is that when a vertex gets thru the video card''s transformation stage, it is stored in a cache memory for a short while. If the same vertex is used while it''s transformed counterpart is in the cache, it doesn''t have to be transformed again.
This is a speed advantage, and usually a surprisingly significant one.

The single quad is too simple to benefit at all from indexing. But in real mesh, as many as 30% of the vertices may be used in more than one triangle.

-Nik

Niko Suni

See that sorta makes sense! Thanks Nik, you always help me out.

D3DVERTEX aCubeVertices[ ] = {	{-1.0f,-1.0f,-1.0f,0.0f,1.0f},{-1.0f, 1.0f,-1.0f,0.0f,0.0f},{1.0f, 1.0f,-1.0f,1.0f,0.0f},				{ 1.0f,-1.0f,-1.0f,1.0f,1.0f},{-1.0f,-1.0f, 1.0f,0.0f,0.0f},{1.0f,-1.0f, 1.0f,0.0f,1.0f},				{ 1.0f, 1.0f, 1.0f,0.0f,0.0f},{-1.0f, 1.0f, 1.0f,0.0f,1.0f}};short aCubeIndices[ ] = {0,1,2,2,3,0,4,5,6,6,7,4,0,3,5,5,4,0,3,2,6,6,5,3,2,1,7,7,6,2,1,0,4,4,7,1}; 


so these 8 Vertices are all referenced 0-8? and then in groups of 3 those Indices are applied to make a triangle!? Thats much easier.

[edited by - EasyGino on October 16, 2003 5:02:58 PM]
A cube is an unfortunate shape for index buffering, since you still have to have duplicate vertices at the corners (because of different normals at each cube face).

However, i see that you got the basic idea though

-Nik

Niko Suni

I stole that code, but I understand it. I would find this index buffer good for terrain generation, maybe :D

This topic is closed to new replies.

Advertisement