Game Development Reference
In-Depth Information
The sample application, reviewed in the next section, gives a concrete
example of how to create a mesh using this function and manually fill in
the mesh's data contents.
Alternatively, you can create an empty mesh with the D3DX-
CreateMesh function. Its prototype is:
HRESULT D3DXCreateMesh(
DWORD NumFaces,
DWORD NumVertices,
DWORD Options,
CONST LPD3DVERTEXELEMENT9* pDeclaration,
LPDIRECT3DDEVICE9 pDevice,
LPD3DXMESH* ppMesh
);
The parameters are similar to D3DXCreateMeshFVF , except for the
fourth. Instead of specifying the FVF, we specify an array of D3DVER-
TEXELEMENT9 structures that describe the format of the vertices. For
now, we leave it to the reader to investigate the D3DVERTEXELEMENT9
structure; however, the following related function is worth mentioning:
HRESULT D3DXDeclaratorFromFVF(
DWORD FVF, // input format
D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]//output format
);
Note: D3DVERTEXELEMENT9 is discussed in Chapter 17.
This function outputs an array of D3DVERTEXELEMENT9 structures
given an FVF as input. Note that MAX_FVF_DECL_SIZE is defined as:
typedef enum {
MAX_FVF_DECL_SIZE = 18
} MAX_FVF_DECL_SIZE;
10.9 Sample Application:
Creating and Rendering a Mesh
The sample application for this chapter renders a mesh of a box (see
Figure 10.5).
Search WWH ::




Custom Search