Game Development Reference
In-Depth Information
Indices for a quad
If we want to draw the given quad without an index buffer, we will need the following:
Vec3(0, 0, 0)
Vec3(1, 0, 0)
Vec3(0, 1, 0)
Vec3(0, 1, 0)
Vec3(1, 0, 0)
Vec3(1, 1, 0)
Now if we use an index buffer, we can just define four vertices and let the index buffer
define the triangles, as follows:
Vec3(0, 0, 0)
Vec3(1, 0, 0)
Vec3(0, 1, 0)
Vec3(1, 1, 0)
Indices = [0, 1, 2, 2, 1, 3]
If you want to create a cube, you just need to define the eight points of the cube and
use indices in the right order to create the triangles. In large models with thousands
or tens of thousands of vertices this can save quite a lot of memory, and allows dy-
namic changes to the model without affecting the original vertex list.
Note
Remember that you can never have a negative index in an array, so Direct3D
only supports unsigned integer values.
Search WWH ::




Custom Search