Vertex and vertex descriptors - GeirGrusom/ModGL GitHub Wiki

Vertex structures

Vertex structures can be created, but because of differing platform padding an absolute offset must be set for every field, and the structure must have explicit layout.


[StructLayout(LayoutKind.Explicit, Size = 32)]
public struct PositionNormalTexCoord
    public static readonly VertexDescriptor Descriptor = VertexDescriptor.Create<PositionNormalTexCoord>();
    public Vector3f Position;
    public Vector3f Normal;
    public Vector2f TexCoord;

Notice the static Descriptor field.

Vertex descriptors

Vertex descriptors describe the different fields of a structure and is used to map fields in a vertex array. They can be created manually, but there should really be little reason to do so. To automatically create a vertex descriptor from a structure type use VertexDescriptor.Create<T>().