Table of Contents

Class VertexDeclaration

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

Defines the layout of the vertices in a Vertex Buffer by specifying its component VertexElements.

[DataContract]
[DataSerializer(typeof(VertexDeclaration.Serializer))]
public sealed class VertexDeclaration : IEquatable<VertexDeclaration>
Inheritance
object
VertexDeclaration
Implements
Extension Methods

Constructors

VertexDeclaration(params VertexElement[])

Initializes a new instance of the VertexDeclaration class.

public VertexDeclaration(params VertexElement[] elements)

Parameters

elements VertexElement[]

The elements that compose a vertex.

VertexDeclaration(VertexElement[], int, int)

Initializes a new instance of the VertexDeclaration class.

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

Parameters

elements VertexElement[]

The elements that compose a vertex.

instanceCount int

The instance count.

vertexStride int

The size of a single vertex in bytes. This is the distance between two consecutive vertices in the Vertex Buffer. Specify 0 to auto-discover the stride from the elements.

Exceptions

ArgumentNullException

elements is null.

Properties

InstanceCount

Gets the instance count.

public int InstanceCount { get; }

Property Value

int

VertexElements

Gets the Vertex Elements that define the layout of the vertices in this declaration.

[DataMember]
public VertexElement[] VertexElements { get; }

Property Value

VertexElement[]

VertexStride

Gets the size, in bytes, of a single vertex in this declaration.

public int VertexStride { get; }

Property Value

int

Methods

CalculateSize()

Calculates the size in bytes of a vertex described by this Vertex Declaration.

public int CalculateSize()

Returns

int

The size in bytes of the vertices using the layout described by this instance.

EnumerateWithOffsets()

Enumerates the Vertex Elements along with their declared offsets.

public IEnumerable<VertexElementWithOffset> EnumerateWithOffsets()

Returns

IEnumerable<VertexElementWithOffset>

A sequence of VertexElementWithOffsets structures.

Equals(VertexDeclaration)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(VertexDeclaration other)

Parameters

other VertexDeclaration

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current object.

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 the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Operators

implicit operator VertexDeclaration(VertexElement)

Performs an implicit conversion from VertexElement to VertexDeclaration, creating a Vertex Declaration with a single Vertex Element.

public static implicit operator VertexDeclaration(VertexElement element)

Parameters

element VertexElement

The single Vertex Element.

Returns

VertexDeclaration

The resulting Vertex Declaration.

implicit operator VertexDeclaration(VertexElement[])

Performs an implicit conversion from an array of VertexElement to VertexDeclaration, creating a Vertex Declaration with the provided Vertex Elements.

public static implicit operator VertexDeclaration(VertexElement[] elements)

Parameters

elements VertexElement[]

The Vertex Elements.

Returns

VertexDeclaration

The resulting Vertex Declaration.