Game Development Reference
In-Depth Information
An example of using the D3DXCreateTeapot function:
ID3DXMesh* mesh = 0;
D3DXCreateTeapot(_device, &mesh, 0);
Once we have generated the mesh data, we can draw it using the
ID3DXMesh::DrawSubset method. This method takes one parame-
ter, which identifies a subset of the mesh. The meshes generated by
the above D3DXCreate* functions create a mesh with only one subset,
so zero can be specified for this parameter. An example of rendering the
mesh:
_device->BeginScene();
mesh->DrawSubset(0);
_device->EndScene();
When you are done with the mesh, you must release it:
_mesh->Release();
_mesh = 0;
3.6 Sample Applications: Triangle,
Cube, Teapot, D3DXCreate*
There are four samples located in this chapter's directory in the topic's
companion files, which can be downloaded from the topic's web site.
Triangle—This very simple application demonstrates how to create
and render a triangle in the wireframe mode.
Cube—A little more advanced than the triangle sample, this appli-
cation renders a spinning wireframe cube.
Teapot—This application uses the D3DXCreateTeapot function
to create and render a spinning teapot.
D3DXCreate—This application creates and renders several differ-
ent kinds of 3D objects that can be created with the D3DXCreate*
functions.
Let's briefly discuss the implementation of the Cube sample. You can
study the others on your own.
The sample application draws and renders a cube, as shown in Fig-
ure 3.4. The project and complete source code for this sample can be
found on this chapter's web page.
Search WWH ::




Custom Search