There are several ready-made functions in D3DX to draw common 3D models
D3dxcreatebox
D3dxcreatesphere
D3dxcreatecylinder//Cylinder
D3dxcreateteapot
D3dxcreatepolygon
D3dxcreatetorus//Torus, similar to donut
These functions have the same three parameters, respectively, which are
1. First parameter lpdirect3ddevice9 pdevice//This is the device used to draw
2. Second-to-last parameter Lpd3dxmesh * Ppmesh//used to store the created mesh
3. Last parameter lpd3dxbuffer * ppadjacency//used to optimize mesh, we set it here to null
Other parameters are related to the specific model, such as box to specify the size, sphere to specify the radius and so on.
Let's take d3dxcreatesphere as an example to explain the general steps of using these functions
Prototype
HRESULT D3dxcreatesphere (
Lpdirect3ddevice9 pdevice,
FLOAT Radius,
UINT Slices,
UINT Stacks,
Lpd3dxmesh * Ppmesh,
Lpd3dxbuffer * ppadjacency
);