Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

GraphicsDevice.DrawIndexedPrimitives Method

Renders the specified geometric primitive, based on indexing into an array of vertices.

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

public void DrawIndexedPrimitives (
         PrimitiveType primitiveType,
         int baseVertex,
         int minVertexIndex,
         int numVertices,
         int startIndex,
         int primitiveCount
)

Parameters

primitiveType
Describes the type of primitive to render. PrimitiveType.PointList is not supported with this method.
baseVertex
Offset to add to each vertex index in the index buffer.
minVertexIndex
Minimum vertex index for vertices used during the call. The minVertexIndex parameter and all of the indices in the index stream are relative to the baseVertex parameter.
numVertices
A number of vertices used during the call. The first vertex is located at index: baseVertex + minVertexIndex.
startIndex
Location in the index array at which to start reading vertices.
primitiveCount
A number of primitives to render. The number of vertices used is a function of primitiveCount and primitiveType. To determine the maximum number of primitives allowed, check the MaxPrimitiveCount property member of the Capabilities structure.

Exception typeCondition
ArgumentOutOfRangeException primitiveCount is less than or equal to zero. When drawing, at least one primitive must be drawn.
InvalidOperationException

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 DrawIndexedPrimitives. 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.
  • Vertices is not a valid vertex buffer, or Indices is not a valid index buffer. A valid vertex buffer and a valid index buffer 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.

The vertex stream and index data of the graphics device must be set before any call to DrawIndexedPrimitives. The following example sets the index data and associates a user-created vertex buffer of type VertexPositionNormalTexture with vertex stream 0 (zero) of the graphics device.

graphics.GraphicsDevice.Vertices[0].SetSource(
    vertexBuffer, 0,
    VertexPositionNormalTexture.SizeInBytes);

graphics.GraphicsDevice.Indices = lineListIndexBuffer;

This method draws indexed primitives from the current set of data input streams.

The minVertexIndex and numVertices parameters specify the range of vertex indices used for each call to DrawIndexedPrimitives. These vertex indices are used to optimize vertex processing of indexed primitives by processing a sequential range of vertices prior to indexing into them. Indices used during this call cannot reference any vertices outside this range.

If no index array is set, DrawIndexedPrimitives fails.

Xbox 360, Windows XP SP2, Windows Vista

Community Additions

ADD
Show:
© 2015 Microsoft