Platform SDK: DirectX

D3DXCreateTorus

The D3DXCreateTorus function creates a torus of given dimensions.

HRESULT D3DXCreateTorus(
  LPDIRECT3DDEVICE7 pDevice,
  float innerRadius,
  float outerRadius,
  DWORD numSides,
  DWORD numRings,
  DWORD numTexCoords,
  ID3DXSimpleShape** ppShape
);

Parameters

pDevice
A pointer to the IDirect3DDevice7 interface of the device.
innerRadius
The inner-radius of the torus. The default value is 1.0f. This parameter should be greater than or equal to 0.0f.
outerRadius
The outer-radius of the torus. The default value is 1.0f. This parameter should be greater than or equal to 0.0f.
numSides
The number of sides in the cross-section. The default value is 8. D3DX_DEFAULT is a valid input for this parameter.
numRings
The number of rings making up the torus. The default value is 8. D3DX_DEFAULT is a valid input for this parameter.
numTexCoords
The number of texture coordinates desired in the output vertex-buffer. The default value is 1. D3DX_DEFAULT is a valid input for this parameter.
ppShape
The address of a pointer to the output vertex-buffer, an ID3DXSimpleShape interface.

Return Values

If the function succeeds, the return value is S_OK.

If the function fails, the return value may be one of the following values:

CLASS_E_NOAGGREGATION
D3DERR_INVALIDPRIMITIVETYPE
D3DERR_INVALIDRAMPTEXTURE
D3DERR_INVALIDVERTEXFORMAT
D3DERR_INVALIDVERTEXTYPE
D3DERR_VBUF_CREATE_FAILED
D3DXERR_INVALIDPARAMETER
D3DXERR_NOMEMORY
D3DXERR_NULLPOINTER
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_OUTOFMEMORY
DDERR_WASSTILLDRAWING

Remarks

The D3DXCreateTorus method draws a doughnut, centered at (0, 0, 0) whose axis is aligned with the z-axis. The inner-radius of the torus is the radius of the cross-section (the minor-radius) and the outer-radius of the torus is the radius of the central hole.

This function returns a vertex buffer that can be used later for drawing or manipulation by the application.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Version: Requires DirectX 7.0.
  Header: Declared in d3dxshapes.h.
  Library: Use d3dx.lib.

See Also

D3DXCreateBox, D3DXCreateCylinder, D3DXCreatePolygon, D3DXCreateSphere, D3DXCreateTeapot