IDirect3DDevice9::CreateIndexBuffer method (d3d9helper.h)
Creates an index buffer.
Syntax
HRESULT CreateIndexBuffer(
[in] UINT Length,
[in] DWORD Usage,
[in] D3DFORMAT Format,
[in] D3DPOOL Pool,
[out, retval] IDirect3DIndexBuffer9 **ppIndexBuffer,
[in] HANDLE *pSharedHandle
);
Parameters
[in] Length
Type: UINT
Size of the index buffer, in bytes.
[in] Usage
Type: DWORD
Usage can be 0, which indicates no usage value. However, if usage is desired, use a combination of one or more D3DUSAGE constants. It is good practice to match the usage parameter in CreateIndexBuffer with the behavior flags in IDirect3D9::CreateDevice. For more information, see Remarks.
[in] Format
Type: D3DFORMAT
Member of the D3DFORMAT enumerated type, describing the format of the index buffer. For more information, see Remarks. The valid settings are the following:
Item | Description |
---|---|
D3DFMT_INDEX16 | Indices are 16 bits each. |
D3DFMT_INDEX32 | Indices are 32 bits each. |
[in] Pool
Type: D3DPOOL
Member of the D3DPOOL enumerated type, describing a valid memory class into which to place the resource.
[out, retval] ppIndexBuffer
Type: IDirect3DIndexBuffer9**
Address of a pointer to an IDirect3DIndexBuffer9 interface, representing the created index buffer resource.
[in] pSharedHandle
Type: HANDLE*
This parameter can be used in Direct3D 9 for Windows Vista to share resources; set it to NULL to not share a resource. This parameter is not used in Direct3D 9 for operating systems earlier than Windows Vista; set it to NULL.
Return value
Type: HRESULT
If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DERR_OUTOFVIDEOMEMORY, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.
Remarks
Index buffers are memory resources used to hold indices, they are similar to both surfaces and vertex buffers. The use of index buffers enables Direct3D to avoid unnecessary data copying and to place the buffer in the optimal memory type for the expected usage.
To use index buffers, create an index buffer, lock it, fill it with indices, unlock it, pass it to IDirect3DDevice9::SetIndices, set up the vertices, set up the vertex shader, and call IDirect3DDevice9::DrawIndexedPrimitive for rendering.
The MaxVertexIndex member of the D3DCAPS9 structure indicates the types of index buffers that are valid for rendering.
Requirements
Requirement | Value |
---|---|
Target Platform | Windows |
Header | d3d9helper.h (include D3D9.h) |
Library | D3D9.lib |