Table of Contents

Class VertexBufferContent

Namespace
Microsoft.Xna.Framework.Content.Pipeline.Processors
Assembly
MonoGame.Framework.Content.Pipeline.dll

Provides methods and properties for managing a design-time vertex buffer that holds packed vertex data.

public class VertexBufferContent : ContentItem
Inheritance
VertexBufferContent
Inherited Members

Remarks

This type directly corresponds to the runtime VertexBuffer class, and when a VertexBufferContent object is passed to the content compiler, the vertex data deserializes directly into a VertexBuffer at runtime. VertexBufferContent objects are not directly created by importers. The preferred method is to store vertex data in the more flexible VertexContent class.

Constructors

VertexBufferContent()

Initializes a new instance of VertexBufferContent.

public VertexBufferContent()

VertexBufferContent(int)

Initializes a new instance of VertexBufferContent of the specified size.

public VertexBufferContent(int size)

Parameters

size int

The size of the vertex buffer content, in bytes.

Properties

VertexData

Gets the array containing the raw bytes of the packed vertex data. Use this method to get and set the contents of the vertex buffer.

public byte[] VertexData { get; }

Property Value

byte[]

Raw data of the packed vertex data.

VertexDeclaration

Gets and sets the associated VertexDeclarationContent object.

public VertexDeclarationContent VertexDeclaration { get; set; }

Property Value

VertexDeclarationContent

The associated VertexDeclarationContent object.

Methods

SizeOf(Type)

Gets the size of the specified type, in bytes.

public static int SizeOf(Type type)

Parameters

type Type

The type.

Returns

int

The size of the specified type, in bytes.

Remarks

Call this method to compute offset parameters for the Write method. If the specified data type cannot be packed into a vertex buffer—for example, if type is not a valid value type—a NotSupportedException is thrown.

Exceptions

NotSupportedException

type is not a valid value type

Write(int, int, Type, IEnumerable)

Writes additional data into the vertex buffer. Writing begins at the specified byte offset, and each value is spaced according to the specified stride value (in bytes).

public void Write(int offset, int stride, Type dataType, IEnumerable data)

Parameters

offset int

Offset at which to begin writing.

stride int

Stride of the data being written, in bytes.

dataType Type

The type of data to be written.

data IEnumerable

The data to write.

Exceptions

NotSupportedException

The specified data type cannot be packed into a vertex buffer.

Write<T>(int, int, IEnumerable<T>)

Writes additional data into the vertex buffer. Writing begins at the specified byte offset, and each value is spaced according to the specified stride value (in bytes).

public void Write<T>(int offset, int stride, IEnumerable<T> data)

Parameters

offset int

Offset to begin writing at.

stride int

Stride of the data being written, in bytes.

data IEnumerable<T>

Enumerated collection of data.

Type Parameters

T

Type being written.

Exceptions

NotSupportedException

The specified data type cannot be packed into a vertex buffer.