D3DXCreateTorus function

Uses a left-handed coordinate system to create a mesh containing a torus.

Syntax

HRESULT D3DXCreateTorus(
  _In_  LPDIRECT3DDEVICE9 pDevice,
  _In_  FLOAT             InnerRadius,
  _In_  FLOAT             OuterRadius,
  _In_  UINT              Sides,
  _In_  UINT              Rings,
  _Out_ LPD3DXMESH        *ppMesh,
  _Out_ LPD3DXBUFFER      *ppAdjacency
);

Parameters

pDevice [in]

Type: LPDIRECT3DDEVICE9

Pointer to an IDirect3DDevice9 interface, representing the device associated with the created torus mesh.

InnerRadius [in]

Type: FLOAT

Inner-radius of the torus. Value should be greater than or equal to 0.0f.

OuterRadius [in]

Type: FLOAT

Outer-radius of the torus. Value should be greater than or equal to 0.0f.

Sides [in]

Type: UINT

Number of sides in a cross-section. Value must be greater than or equal to 3.

Rings [in]

Type: UINT

Number of rings making up the torus. Value must be greater than or equal to 3.

ppMesh [out]

Type: LPD3DXMESH*

Address of a pointer to the output shape, an ID3DXMesh interface.

ppAdjacency [out]

Type: LPD3DXBUFFER*

Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return value

Type: HRESULT

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created torus is centered at the origin, and its 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 mesh that can be used later for drawing or manipulation by the application.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Requirements

Requirement Value
Header
D3dx9shape.h
Library
D3dx9.lib

See also

Shape Drawing Functions