Game Development Reference
In-Depth Information
Figure 3.4 A screen shot
from the CubeApp sample
First we instantiate the following two global variables to hold the ver-
tex and index data of our cube:
IDirect3DVertexBuffer9* VB = 0;
IDirect3DIndexBuffer9* IB = 0;
In addition, we instantiate two constant global variables that define the
resolution of our screen:
const int Width = 800;
const int Height = 600;
We then define our vertex structure and the flexible vertex format of
that structure. The vertex structure in this sample holds only vertex
position information:
struct Vertex
{
Vertex(){}
Vertex(float x, float y, float z)
{
_x=x; _y=y; _z=z;
}
float _x, _y, _z;
static const DWORD FVF;
};
const DWORD Vertex::FVF = D3DFVF_XYZ;
Let's move on to the framework functions. The Setup function creates
the vertex and index buffers, locks them, writes the vertices that make
up the cube to the vertex buffer, and writes the indices that define the
triangles of the cube. It then moves the camera a few units back so that
it can see the cube that will be rendered at the origin of the world.
Then it sets the projection transform. Finally, it sets the fill mode ren-
der state to wireframe mode:
bool Setup()
{
Search WWH ::




Custom Search