Class DynamicIndexBuffer
Describes the rendering order of the vertices in a vertex buffer. Use DynamicIndexBuffer for storing indices for dynamic vertices and IndexBuffer for indices of non-dynamic arrays.
public class DynamicIndexBuffer : IndexBuffer, IDisposable
- Inheritance
-
DynamicIndexBuffer
- Implements
- Inherited Members
Remarks
For more information on drawing with dynamic buffers, see DynamicVertexBuffer Class
Constructors
DynamicIndexBuffer(GraphicsDevice, IndexElementSize, int, BufferUsage)
Initializes a new instance of DynamicIndexBuffer with the specified parameters.
public DynamicIndexBuffer(GraphicsDevice graphicsDevice, IndexElementSize indexElementSize, int indexCount, BufferUsage usage)
Parameters
graphicsDevice
GraphicsDeviceThe associated graphics device of the index buffer.
indexElementSize
IndexElementSizeThe size, in bits, of an index element.
indexCount
intNumber of indices in the buffer.
usage
BufferUsageA set of options identifying the behaviors of this index buffer resource.
Exceptions
- ArgumentNullException
graphicsDevice
is null.- ArgumentOutOfRangeException
One of the following conditions is true
-
The
indexCount
parameter is invalid. Index buffers can only be created for indices which are sixteen or thirty-two bits in length -
The
indexElementSize
parameter is invalid. The resource size must be greater than zero. -
The
indexElementSize
parameter is invalid. The total size of the index buffer must be an even multiple of the index element size (either 16 or 32 bits).
-
The
DynamicIndexBuffer(GraphicsDevice, Type, int, BufferUsage)
Initializes a new instance of DynamicIndexBuffer with the specified parameters.
public DynamicIndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage)
Parameters
graphicsDevice
GraphicsDeviceThe associated graphics device of the index buffer.
indexType
TypeType to use for index values.
indexCount
intNumber of indices in the buffer.
usage
BufferUsageA set of options identifying the behaviors of this index buffer resource.
Exceptions
- ArgumentNullException
graphicsDevice
is null.- ArgumentOutOfRangeException
The
indexCount
parameter is invalid. It must be greater than zero, and the index must be sixteen or thirty-two bits in length. Index buffers can only be created for indices which are sixteen or thirty-two bits in length.- InvalidOperationException
The resource could not be created
Properties
IsContentLost
Gets a value that indicates whether the index buffer data has been lost due to a lost device event.
public bool IsContentLost { get; }
Property Value
Methods
SetData<T>(int, T[], int, int, SetDataOptions)
Copies array data to the index buffer.
public void SetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
Parameters
offsetInBytes
intNumber of bytes into the index buffer where copying will start.
data
T[]The array of data to copy.
startIndex
intThe index of the element in the array at which to start copying.
elementCount
intThe number of elements to copy.
options
SetDataOptionsSpecifies whether existing data in the buffer will be kept after this operation.
Type Parameters
T
The type of elements in the array.
Remarks
An InvalidOperationException is thrown if an attempt is made to modify (for example, calls to the SetData method) a resource that is currently set on a graphics device.
SetData<T>(T[], int, int, SetDataOptions)
Copies array data to the index buffer.
public void SetData<T>(T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
Parameters
data
T[]The array of data to copy.
startIndex
intThe index of the element in the array at which to start copying.
elementCount
intThe number of elements to copy.
options
SetDataOptionsSpecifies whether existing data in the buffer will be kept after this operation.
Type Parameters
T
The type of elements in the array.
Remarks
An InvalidOperationException is thrown if an attempt is made to modify (for example, calls to the SetData method) a resource that is currently set on a graphics device.