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

Renders indexed primitives from a 16-bit index buffer, a vertex declaration, and other related input parameters.

Syntax

'Declaration
Public Sub DrawUserIndexedPrimitives(Of T As Struct) ( _
         primitiveType As PrimitiveType, _
         vertexData As T(), _
         vertexOffset As Integer, _
         numVertices As Integer, _
         indexData As Short(), _
         indexOffset As Integer, _
         primitiveCount As Integer, _
         vertexDeclaration As VertexDeclaration _
)
public void DrawUserIndexedPrimitives<T> (
         PrimitiveType primitiveType,
         T[] vertexData,
         int vertexOffset,
         int numVertices,
         short[] indexData,
         int indexOffset,
         int primitiveCount,
         VertexDeclaration vertexDeclaration
) where T : struct
public:
generic<typename T> where T : struct
void DrawUserIndexedPrimitives(
         PrimitiveType primitiveType,
         T vertexData[],
         int vertexOffset,
         int numVertices,
         short indexData[],
         int indexOffset,
         int primitiveCount,
         VertexDeclaration vertexDeclaration
)

Type Parameters

  • T
    Per-vertex data type.

Parameters

  • primitiveType
    Type: PrimitiveType
    The primitive type.
  • vertexData
    Type: T
    The vertex data.
  • vertexOffset
    Type: Int32
    Offset (in vertices) from the beginning of the vertex buffer to the first vertex to draw.
  • numVertices
    Type: Int32
    Number of vertices to draw.
  • indexData
    Type: Int16
    The index data.
  • indexOffset
    Type: Int32
    Offset (in indices) from the beginning of the index buffer to the first index to use.
  • primitiveCount
    Type: Int32
    Number of primitives to render.
  • vertexDeclaration
    Type: VertexDeclaration
    The vertex declaration.

Exceptions

Exception type Condition
ArgumentException

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.
InvalidOperationException

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.

Requirements

Namespace: Microsoft.Xna.Framework.Graphics

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

See Also

Reference

GraphicsDevice Class
GraphicsDevice Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Windows Phone