Table of Contents

Class VertexDeclaration

Namespace
Microsoft.Xna.Framework.Graphics
Assembly
MonoGame.Framework.dll

Defines per-vertex data of a vertex buffer.

public class VertexDeclaration : GraphicsResource, IDisposable, IEquatable<VertexDeclaration>
Inheritance
VertexDeclaration
Implements
Inherited Members

Remarks

VertexDeclaration implements IEquatable<T> and can be used as a key in a dictionary. Two vertex declarations are considered equal if the vertices are structurally equivalent, i.e. the vertex elements and the vertex stride are identical. (The properties Name and Tag are ignored in GetHashCode() and Equals(VertexDeclaration)!)

Constructors

VertexDeclaration(params VertexElement[])

Initializes a new instance of the VertexDeclaration class.

public VertexDeclaration(params VertexElement[] elements)

Parameters

elements VertexElement[]

The vertex elements.

Exceptions

ArgumentNullException

elements is null or empty.

VertexDeclaration(int, params VertexElement[])

Initializes a new instance of the VertexDeclaration class.

public VertexDeclaration(int vertexStride, params VertexElement[] elements)

Parameters

vertexStride int

The size of a vertex (including padding) in bytes.

elements VertexElement[]

The vertex elements.

Exceptions

ArgumentNullException

elements is null or empty.

Properties

VertexStride

Gets the size of a vertex (including padding) in bytes.

public int VertexStride { get; }

Property Value

int

The size of a vertex (including padding) in bytes.

Methods

Equals(VertexDeclaration)

Determines whether the specified VertexDeclaration is equal to this instance.

public bool Equals(VertexDeclaration other)

Parameters

other VertexDeclaration

The object to compare with the current object.

Returns

bool

true if the specified VertexDeclaration is equal to this instance; otherwise, false.

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

GetVertexElements()

Gets a copy of the vertex elements.

public VertexElement[] GetVertexElements()

Returns

VertexElement[]

A copy of the vertex elements.

Operators

operator ==(VertexDeclaration, VertexDeclaration)

Compares two VertexElement instances to determine whether they are the same.

public static bool operator ==(VertexDeclaration left, VertexDeclaration right)

Parameters

left VertexDeclaration

The first instance.

right VertexDeclaration

The second instance.

Returns

bool

true if the left and right are the same; otherwise, false.

operator !=(VertexDeclaration, VertexDeclaration)

Compares two VertexElement instances to determine whether they are different.

public static bool operator !=(VertexDeclaration left, VertexDeclaration right)

Parameters

left VertexDeclaration

The first instance.

right VertexDeclaration

The second instance.

Returns

bool

true if the left and right are the different; otherwise, false.