Microsoft DirectX 8.1 (Visual Basic)

Direct3DDevice8.CreateIndexBuffer

Creates an index buffer.

object.CreateIndexBuffer( _ 
    LengthInBytes As Long, _ 
    Usage As Long, _ 
    Format As CONST_D3DFORMAT, _ 
    Pool As CONST_D3DPOOL) As Direct3DIndexBuffer8

Parts

object
Object expression that resolves to a Direct3DDevice8 object.
LengthInBytes
Size of the index buffer, in bytes.
Usage
A combination of one or more of the following flags defined by the CONST_D3DUSAGEFLAGS enumeration, describing the usage controls for this resource.
D3DUSAGE_DONOTCLIP
Set to indicate that the index buffer content will never require clipping.
D3DUSAGE_DYNAMIC
Set to indicate when the vertex or index buffer requires dynamic memory usage. This usage is useful for drivers because it enables them to decide where to place the driver. In general, static vertex buffers are placed in video memory and dynamic vertex buffers are placed in AGP memory. Note that there is no separate static usage; if you do not specify D3DUSAGE_DYNAMIC the vertex buffer is made static. D3DUSAGE_DYNAMIC is strictly enforced through the D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE locking flags. As a result, D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE are valid only on vertex and index buffers created with D3DUSAGE_DYNAMIC; they are not valid flags on static vertex buffers.

Note that D3DUSAGE_DYNAMIC cannot be specified on managed vertex and index buffers. For more information, see Managing Resources.

D3DUSAGE_RTPATCHES
Set to indicate when the index buffer is to be used for drawing high-order primitives.
D3DUSAGE_NPATCHES
Set to indicate when the index buffer is to be used for drawing N patches.
D3DUSAGE_POINTS
Set to indicate when the index buffer is to be used for drawing point sprites or indexed point lists.
D3DUSAGE_SOFTWAREPROCESSING
Set to indicate that the buffer is to be used with software processing.
D3DUSAGE_WRITEONLY
Informs the system that the application writes only to the index buffer. Using this flag enables the driver to select the best memory location for efficient write operations and rendering. Attempts to read from an index buffer that is created with this capability can result in degraded performance.
Format
Member of the CONST_D3DFORMAT enumeration, describing the format of the index buffer. The valid settings are the following:
D3DFMT_INDEX16
Indices are 16 bits each.
D3DFMT_INDEX32
Indices are 32 bits each. See Remarks.
Pool
Member of the CONST_D3DPOOL enumeration, describing a valid memory class into which to place the resource.

Return Values

A Direct3DIndexBuffer8 object, representing the created index buffer resource.

Error Codes

If the method fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
D3DERR_OUTOFVIDEOMEMORY
D3DXERR_INVALIDDATA
E_OUTOFMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

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 Microsoft® 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 Direct3DDevice8.SetIndices, set up the vertices, set up the vertex shader, and call Direct3DDevice8.DrawIndexedPrimitive for rendering.

The MaxVertexIndex member of the D3DCAPS8 type indicates the types of index buffers that are valid for rendering.

See Also

Direct3DIndexBuffer8.GetDesc