Game Development Reference
In-Depth Information
3.4.3
Begin/End Scene
The last bit of information to mention is that all drawing methods must
be called inside an
IDirect3DDevice9::BeginScene
and
IDirect3DDevice9::EndScene
pair. For example, we would write:
_device->BeginScene();
_device->DrawPrimitive(...);
_device->EndScene();
3.5
D3DX Geometric Objects
Building 3D objects by constructing each triangle in code is tedious.
Fortunately, the D3DX library provides some methods to generate the
mesh data of simple 3D objects for us.
The D3DX library provides the following six mesh creation
functions:
D3DXCreateBox
D3DXCreateSphere
D3DXCreateCylinder
D3DXCreateTeapot
D3DXCreatePolygon
D3DXCreateTorus
Figure 3.3: Objects created and
rendered using the
D3DXCreate*
functions
All six are used similarly and use the D3DX mesh data structure
ID3DXMesh
as well as the
ID3DXBuffer
interface. These interfaces
are covered in Chapters 10 and 11. For now, we ignore their details and
concentrate on using them in the simplest way.
HRESULT D3DXCreateTeapot(
LPDIRECT3DDEVICE9 pDevice, // device associated with the mesh
LPD3DXMESH* ppMesh, // pointer to receive mesh
LPD3DXBUFFER* ppAdjacency // set to zero for now
);
Team-Fly
®
Search WWH ::
Custom Search