VertexBuffer.SetData Generic Method (T )

Sets vertex buffer data.

Syntax

'Declaration
Public Sub SetData(Of T As ValueType) ( _
         data As T() _
)
public void SetData<T> (
         T[] data
) where T : ValueType
public:
generic<typename T> where T : ValueType
void SetData(
         T data[]
)

Type Parameters

  • T
    The type of the elements in the array.

Parameters

  • data
    Type: T
    Array of data.

Exceptions

Exception type Condition
ArgumentNullException data is null.
ArgumentOutOfRangeException One of the following conditions is true:
  • The vertex stride is larger than the vertex buffer.
  • The vertex stride is too small for the type of data requested.
InvalidOperationException The array is not the correct size for the amount of data requested.

Example

This example demonstrates how to create a vertex buffer to hold a list of vertices and set the data for the vertex buffer to the array of vertices.

// Initialize the vertex buffer, allocating memory for each vertex.
vertexBuffer = new VertexBuffer(graphics.GraphicsDevice, vertexDeclaration,
    points, BufferUsage.None);

// Set the vertex buffer data to the array of vertices.
vertexBuffer.SetData<VertexPositionColor>(primitiveList);
// Initialize the vertex buffer, allocating memory for each vertex.
vertexBuffer = new VertexBuffer(graphics.GraphicsDevice, vertexDeclaration,
    points, BufferUsage.None);

// Set the vertex buffer data to the array of vertices.
vertexBuffer.SetData<VertexPositionColor>(primitiveList);

Requirements

Namespace: Microsoft.Xna.Framework.Graphics

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

See Also

Reference

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

Platforms

Windows Phone