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

Renders geometric primitives with indexed data specified by the user, specifying an index buffer as an array of type Int16.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

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

Type Parameters

The type of vertex in vertexData.


Describes the type of primitive to render.
The vertex buffer indexed by indexData.
Offset to add to each vertex index in the index buffer.
Number of vertices used during this call. The first vertex is located at index minVertexIndex.
A list of indices into the vertex buffer, given in the order that you want the vertices to render. Using an array of type Int16, which uses 16 bits per element, allows you to conserve resources if the index buffer does not require a 32-bit depth array.
Location in the index array at which to start reading vertices.
Number of primitives to render. The maximum number of primitives allowed is determined by checking MaxPrimitiveCount. (The number of indices is a function of the primitive count and the primitive type.)

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:

  • VertexDeclaration is not a valid value. A valid vertex declaration must be set on the device before any draw operations can be performed.
  • A valid vertex shader and pixel shader was not set before calling DrawUserIndexedPrimitives. Both a valid vertex shader and pixel shader (or valid effect) must be set on the device before any draw operations may be performed. See How To: Use BasicEffect or How To: Create and Apply Custom Effects for more information on applying effects.
  • 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.
  • The active render target and depth stencil surface do not have the same pixel size and multisampling type.

Xbox 360, Windows XP SP2, Windows Vista

Community Additions