DrawUserPrimitives Generic Method
Collapse the table of content
Expand the table of content

GraphicsDevice.DrawUserPrimitives Generic Method

Renders the given geometric primitive with data specified by the user.

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

public void DrawUserPrimitives<T> (
         PrimitiveType primitiveType,
         T[] vertexData,
         int vertexOffset,
         int primitiveCount
) where T : ValueType

Type Parameters



Describes the type of primitive to render.
The vertex data.
Offset at which to begin reading vertexData.
Number of primitives to render. The maximum number of primitives allowed is determined by checking MaxPrimitiveCount. The number of indices is a function of primitiveCount and primitiveType.

Exception typeCondition
ArgumentExceptionvertexOffset + numVertices is outside of the range of vertexData.
ArgumentNullException vertexData is null.

One of the following conditions is true:

  • primitiveCount is less than or equal to zero. When drawing, at least one primitive must be drawn.
  • vertexOffset is less than zero or greater than the length of vertexData.

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 DrawUserPrimitives. 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. A valid vertex buffer must be set on the device before any draw operations may be performed.

This method is intended for use when drawing dynamic geometry specified by the user. It supports only a single vertex stream. The effect of this call is to use the provided vertex data pointer and stride for vertex stream 0. It is invalid to have the declaration of the current vertex shader refer to vertex streams other than stream 0.

The vertex data passed to DrawUserPrimitives does not need to persist after the call. Access to the data is completed before returning from the call.

Xbox 360, Windows XP SP2, Windows Vista

Community Additions

© 2016 Microsoft