Share via


IndexBuffer.IndexBuffer(Device,Int32,Usage,Pool,Boolean) Constructor (Microsoft.DirectX.Direct3D)

Creates a new instance of the IndexBuffer class.

Definition

Visual Basic Public Sub New( _
    ByVal device As Device, _
    ByVal sizeOfBufferInBytes As Integer, _
    ByVal usage As Usage, _
    ByVal pool As Pool, _
    ByVal sixteenBitIndices As Boolean _
)
C# public IndexBuffer(
    Device device,
    int sizeOfBufferInBytes,
    Usage usage,
    Pool pool,
    bool sixteenBitIndices
);
C++ public:
 IndexBuffer(
    Devicedevice,
    int sizeOfBufferInBytes,
    Usage usage,
    Pool pool,
    bool sixteenBitIndices
);
JScript public function IndexBuffer(
    device : Device,
    sizeOfBufferInBytes : int,
    usage : Usage,
    pool : Pool,
    sixteenBitIndices : boolean
);

Parameters

device Microsoft.DirectX.Direct3D.Device
The Device object to associate with the index buffer.
sizeOfBufferInBytes System.Int32
Size of the index buffer in bytes.
usage Microsoft.DirectX.Direct3D.Usage
Usage can be 0, which indicates no usage value. However, if usage is desired, use a combination of one or more Usage flags. It is good practice to match the param_Usage_usage parameter in the IndexBuffer constructor with the behavior flags in the Device constructor. See Remarks.
pool Microsoft.DirectX.Direct3D.Pool
Member of the Pool enumerated type that describes a valid memory class into which to place the resource.
sixteenBitIndices System.Boolean
Set to true if the index buffer contains 16-bit indices. Set to false if the index buffer contains 32-bit indices.

Remarks

Index buffers are memory resources used to hold indices. They are similar to 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 Device.Indices, set up the vertices, set up the vertex shader, and call Device.DrawIndexedPrimitives for rendering.

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

Exceptions

InvalidCallException

The method call is invalid. For example, a method's parameter might contain an invalid value.

InvalidDataException

The data is invalid.

OutOfVideoMemoryException

Direct3D does not have enough display memory to perform the operation.

OutOfMemoryExceptionLeave Site

Direct3D could not allocate sufficient memory to complete the call.

See Also