Game Development Reference
In-Depth Information
10.8 Creating a Mesh (D3DXCreateMeshFVF)
Thus far, we have created mesh objects using the D3DXCreate* func-
tions. However, we can also create an “empty” mesh using the
D3DXCreateMeshFVF function. By empty mesh, we mean that we
specify the number of faces and vertices that we want the mesh to be
able to hold; then D3DXCreateMeshFVF allocates the appropriately
sized vertex, index, and attribute buffers. Once we have the mesh's
buffers allocated, we manually fill in the mesh's data contents (that is,
we must write the vertices, indices, and attributes to the vertex buffer,
index buffer, and attribute buffer, respectively).
As said, to create an empty mesh we use the D3DXCreateMesh-
FVF function:
HRESULT D3DXCreateMeshFVF(
DWORD NumFaces,
DWORD NumVertices,
DWORD Options,
DWORD FVF,
LPDIRECT3DDEVICE9 pDevice,
LPD3DXMESH* ppMesh
);
NumFaces —The number of faces the mesh will have. This must
be greater than zero.
NumVertices —The number of vertices the mesh will have. This
must be greater than zero.
Options —One or more creation flags that will be used to create
the mesh. See the D3DXMESH enumerated type in the SDK docu-
mentation for a complete list of option flags. Some common flags
are:
D3DXMESH_32BIT —The mesh will use 32-bit indices.
D3DXMESH_MANAGED —The mesh will be placed in the man-
aged memory pool.
D3DXMESH_WRITEONLY —The mesh's data will only be writ-
ten to and not read from.
D3DXMESH_DYNAMIC —The mesh's buffers will be made
dynamic.
FVF —The flexible vertex format of the vertices stored in this
mesh
pDevice —The device associated with the mesh
ppMesh —Outputs the created mesh
Search WWH ::




Custom Search