Class VertexDeclaration
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
-
objectVertexDeclaration
- Implements
- Extension Methods
Constructors
VertexDeclaration(params VertexElement[])
Initializes a new instance of the VertexDeclaration class.
public VertexDeclaration(params VertexElement[] elements)
Parameters
elementsVertexElement[]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
elementsVertexElement[]The elements that compose a vertex.
instanceCountintThe instance count.
vertexStrideintThe size of a single vertex in bytes. This is the distance between two consecutive vertices in the Vertex Buffer. Specify
0to auto-discover the stride from theelements.
Exceptions
- ArgumentNullException
elementsis null.
Properties
InstanceCount
Gets the instance count.
public int InstanceCount { get; }
Property Value
VertexElements
Gets the Vertex Elements that define the layout of the vertices in this declaration.
[DataMember]
public VertexElement[] VertexElements { get; }
Property Value
VertexStride
Gets the size, in bytes, of a single vertex in this declaration.
public int VertexStride { get; }
Property Value
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
otherVertexDeclarationAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current object.
Returns
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
elementVertexElementThe 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
elementsVertexElement[]The Vertex Elements.
Returns
- VertexDeclaration
The resulting Vertex Declaration.