public final class VertexFormat

  1. Object
  2. VertexFormat
An ordered, interleaved layout of VertexAttributes describing how the floats of a VertexBuffer are grouped into vertices. All attributes are tightly packed in declaration order; the stride is the sum of the component counts. A handful of common formats are provided as constants.

Fields

public static final VertexFormat POSITIONPosition only (3 floats).
public static final VertexFormat POSITION_TEXCOORDPosition and texture coordinate (3 + 2 floats).
public static final VertexFormat POSITION_NORMALPosition and normal (3 + 3 floats).
public static final VertexFormat POSITION_NORMAL_TEXCOORDPosition, normal and texture coordinate (3 + 3 + 2 floats).

Constructors

public VertexFormat(VertexAttribute[] attributes)Creates a vertex format from the supplied attributes in interleaved order.

Methods

public int getAttributeCount()Returns the number of attributes in this format.
public VertexAttribute getAttribute(int index)Returns the attribute at the supplied index in declaration order.
public int getAttributeOffset(int index)Returns the float offset of the attribute at the supplied index within a vertex.
public VertexAttribute findByUsage(VertexAttribute.Usage usage)Returns the first attribute matching the supplied usage, or null when the format does not contain it.
public int getFloatsPerVertex()Returns the number of floats that make up a single vertex (the stride measured in floats).
public int getStrideBytes()Returns the stride of a vertex in bytes.

Inherited methods

Field details

POSITION

public static final VertexFormat POSITION
Position only (3 floats).

POSITION_TEXCOORD

public static final VertexFormat POSITION_TEXCOORD
Position and texture coordinate (3 + 2 floats).

POSITION_NORMAL

public static final VertexFormat POSITION_NORMAL
Position and normal (3 + 3 floats).

POSITION_NORMAL_TEXCOORD

public static final VertexFormat POSITION_NORMAL_TEXCOORD
Position, normal and texture coordinate (3 + 3 + 2 floats). The common format for lit, textured meshes.

Constructor details

VertexFormat

public VertexFormat(VertexAttribute[] attributes)
Creates a vertex format from the supplied attributes in interleaved order.

Parameters

attributes VertexAttribute[]
the attributes that make up a single vertex

Method details

getAttributeCount

public int getAttributeCount()
Returns the number of attributes in this format.

getAttribute

public VertexAttribute getAttribute(int index)
Returns the attribute at the supplied index in declaration order.

getAttributeOffset

public int getAttributeOffset(int index)
Returns the float offset of the attribute at the supplied index within a vertex.

findByUsage

public VertexAttribute findByUsage(VertexAttribute.Usage usage)
Returns the first attribute matching the supplied usage, or null when the format does not contain it.

getFloatsPerVertex

public int getFloatsPerVertex()
Returns the number of floats that make up a single vertex (the stride measured in floats).

getStrideBytes

public int getStrideBytes()
Returns the stride of a vertex in bytes.