Game Development Reference
In-Depth Information
Chapter 3
Drawing in Direct3D
In the last chapter we learned the concepts of creating and rendering a
scene. In this chapter we put that into practice and learn how to draw
some geometric objects in Direct3D. The Direct3D interfaces and
methods covered in this chapter are of some importance, for they are
used throughout the rest of this topic.
Objectives
To find out how vertex and index data is stored in Direct3D
To discover how to change the way geometry is rendered using
render states
To learn how to render a scene
To learn how to create more complex 3D shapes using the
D3DXCreate* functions
3.1 Vertex/Index Buffers
Vertex and index buffers are similar interfaces and share similar meth-
ods; therefore we cover them together. A vertex buffer is simply a
chunk of contiguous memory that contains vertex data. Similarly, an
index buffer is a chunk of contiguous memory that contains index data.
We use vertex and index buffers to hold our data over arrays because
vertex and index buffers can be placed in video memory. Rendering
data from video memory is done much faster than rendering data in
system memory.
In code, a vertex buffer is represented by the IDirect3DVer-
texBuffer9 interface and an index buffer is represented by the
IDirect3DIndexBuffer9 interface.
75
Search WWH ::




Custom Search