Using Index Buffers

If you remember our first application rendering cubes, we created data for a total of 36 vertices. There were 2 triangles for each face of the cube; 6 faces multiplied by 2 triangles equals 12 primitives. Since each primitive has 3 vertices, we get our 36. However, in reality, there were only 8 different vertices being used; one for each corner of the cube.

Storing the same vertex data multiple times in a small application such as this may not seem like that big of a deal, but in a large-scale application where you're storing mass amounts of vertex data, saving room by not duplicating your vertices is nothing but a good thing. Luckily, Direct3D has a mechanism for sharing vertex data inside a primitive called index buffers. ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.