Class VertexFormat
java.lang.Object
com.codename1.gpu.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.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VertexFormatPosition only (3 floats).static final VertexFormatPosition and normal (3 + 3 floats).static final VertexFormatPosition, normal and texture coordinate (3 + 3 + 2 floats).static final VertexFormatPosition and texture coordinate (3 + 2 floats). -
Constructor Summary
ConstructorsConstructorDescriptionVertexFormat(VertexAttribute[] attributes) Creates a vertex format from the supplied attributes in interleaved order. -
Method Summary
Modifier and TypeMethodDescriptionfindByUsage(VertexAttribute.Usage usage) Returns the first attribute matching the supplied usage, or null when the format does not contain it.getAttribute(int index) Returns the attribute at the supplied index in declaration order.intReturns the number of attributes in this format.intgetAttributeOffset(int index) Returns the float offset of the attribute at the supplied index within a vertex.intReturns the number of floats that make up a single vertex (the stride measured in floats).intReturns the stride of a vertex in bytes.
-
Field Details
-
POSITION
Position only (3 floats). -
POSITION_TEXCOORD
Position and texture coordinate (3 + 2 floats). -
POSITION_NORMAL
Position and normal (3 + 3 floats). -
POSITION_NORMAL_TEXCOORD
Position, normal and texture coordinate (3 + 3 + 2 floats). The common format for lit, textured meshes.
-
-
Constructor Details
-
VertexFormat
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
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
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.
-