Class VertexFormat

java.lang.Object
com.codename1.gpu.VertexFormat

public final class VertexFormat extends Object
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.
  • 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: 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.