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
graphicsDeviceGraphicsDeviceThe associated graphics device of the index buffer.
indexElementSizeIndexElementSizeThe size, in bits, of an index element.
indexCountintNumber of indices in the buffer.
usageBufferUsageA set of options identifying the behaviors of this index buffer resource.
Exceptions
- ArgumentNullException
graphicsDeviceis null.- ArgumentOutOfRangeException
One of the following conditions is true
-
The
indexCountparameter is invalid. Index buffers can only be created for indices which are sixteen or thirty-two bits in length -
The
indexElementSizeparameter is invalid. The resource size must be greater than zero. -
The
indexElementSizeparameter 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
graphicsDeviceGraphicsDeviceThe associated graphics device of the index buffer.
indexTypeTypeType to use for index values.
indexCountintNumber of indices in the buffer.
usageBufferUsageA set of options identifying the behaviors of this index buffer resource.
Exceptions
- ArgumentNullException
graphicsDeviceis null.- ArgumentOutOfRangeException
The
indexCountparameter 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
offsetInBytesintNumber of bytes into the index buffer where copying will start.
dataT[]The array of data to copy.
startIndexintThe index of the element in the array at which to start copying.
elementCountintThe number of elements to copy.
optionsSetDataOptionsSpecifies whether existing data in the buffer will be kept after this operation.
Type Parameters
TThe 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
dataT[]The array of data to copy.
startIndexintThe index of the element in the array at which to start copying.
elementCountintThe number of elements to copy.
optionsSetDataOptionsSpecifies whether existing data in the buffer will be kept after this operation.
Type Parameters
TThe 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.