GraphicsDevice.DrawUserIndexedPrimitives Generic Method (PrimitiveType, T[], Int32, Int32, Int32[], Int32, Int32)

Renders indexed primitives from a 32-bit index buffer and other related input parameters.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in

public void DrawUserIndexedPrimitives<T> (
         PrimitiveType primitiveType,
         T[] vertexData,
         int vertexOffset,
         int numVertices,
         int[] indexData,
         int indexOffset,
         int primitiveCount
) where T : 

Type Parameters

Per-vertex data type.


Type: PrimitiveType
The primitive type.
Type: T
The vertex data.
Type: Int32
Offset (in vertices) from the beginning of the vertex buffer to the first vertex to draw.
Type: Int32
Number of vertices to draw.
Type: Int32
The index data.
Type: Int32
Offset (in indices) from the beginning of the index buffer to the first index to use.
Type: Int32
Number of primitives to render.

Exception typeCondition

One of the following conditions is true:

  • vertexOffset + numVertices is outside of the range of vertexData.
  • There are not enough indices in indexData based on the number of primitives requested by primitiveCount.
ArgumentNullException vertexData or indexData is null.
ArgumentOutOfRangeException One of the following conditions is true:
  • indexOffset or vertexOffset is not in a range allowed by indexData or vertexData.
  • primitiveCount or numVertices is less than or equal to zero. When drawing, at least one primitive must be drawn.

One of the following conditions is true:

  • A valid VertexDeclaration must be set on the device before any draw operations can be performed.
  • A valid vertex shader was not set before calling DrawUserIndexedPrimitives. A valid vertex shader or valid effect must be set on the device before any draw operations may be performed. See Creating a Basic Effect for more information about using an effect.
  • vertexData is not a valid vertex buffer, or indexData is not a valid index buffer. A valid vertex buffer (and a valid index buffer if you are using indexed primitives) must be set on the device before any draw operations may be performed.
NotSupportedException The profile does not support an elementSize of IndexElementSize.ThirtyTwoBits; use IndexElementSize.SixteenBits or a type that has a size of two bytes.

Xbox 360, Windows 7, Windows Vista, Windows XP

Community Additions