vertex buffer and index buffer?

Started by
1 comment, last by alnite 21 years, 2 months ago
I am reading Focus on 2D in Direct3D right now, but I got confused with Vertex Buffer and Index Buffer. I pretty much understand what vertex buffers is, a collection of vertices that you want to render on the screen. But then, the author explains something about shared vertices. Like those in a rectangle, formed by 2 triangles, thus there are 6 vertices, but you only need 4 vertices. So, the author says:
quote:Focus on 2D in Direct3D, page 51 Rather than fill the vertex buffer with six vertices with duplicates, you can put only four vertices into vertex buffer, and place six entries in the index buffer.
I look at the DirectX SDK tutorials, in Tutorial 2: Rendering Vertices. The tutorial uses vertex buffer with four vertices to draw a rectangle, but it does not use any index buffer. So..what''s the point of index buffer? If I can fill in vertex buffer with only four vertices, why should I fill index buffer with six vertices? 500
Advertisement
Some primitive types (like fans and strips) share vertices. Although that''s good, indexed lists are often preferable because they don''t constrain you in the ways that list and fans constrain you.

Essentially, fans and strips share vertices that are ordered in certain ways in the vertex buffer. An index buffer allows you to point into the vertex buffer in arbitrary ways.

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Here is an example and explanation of what index buffers are in relation to vertex buffers and what the advantages are such as reducing your vertex usage less stress on the video card such as a terrain mesh made up of thousands of vertices.

http://www.andypike.com/tutorials/directx8/008.asp

As well as other dX8 tutorials.

http://www.andypike.com/tutorials/directx8/

Doug

This topic is closed to new replies.

Advertisement