Platform SDK: DirectX

D3DXCreateSphere

The D3DXCreateSphere function creates a sphere of given dimensions.

HRESULT D3DXCreateSphere(
  LPDIRECT3DDEVICE7 pDevice,
  float radius,
  DWORD numSlices,
  DWORD numStacks,
  DWORD numTexCoords,
  ID3DXSimpleShape** ppShape
);

Parameters

pDevice
A pointer to the IDirect3DDevice7 interface of the device.
radius
The radius of the sphere. The default value is 1.0f. This parameter should be greater than or equal to 0.0f.
numSlices
The number of slices about the main axis. The default value is 8. D3DX_DEFAULT is a valid input for this parameter.
numStacks
The number of stacks along the main axis. 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

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, D3DXCreateTeapot, D3DXCreateTorus