APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.graphics

public final Class VertexAttribute

extends Object
Class Inheritance
Imports
com.badlogic.gdx.graphics.VertexAttributes.Usage, com.badlogic.gdx.graphics.glutils.ShaderProgram

A single vertex attribute defined by its Usage, its number of components and its shader alias. The Usage is used for uniquely identifying the vertex attribute from among its VertexAttributes siblings. The number of components defines how many components the attribute has. The alias defines to which shader attribute this attribute should bind. The alias is used by a Mesh when drawing with a ShaderProgram. The alias can be changed at any time.
Author
mzechner

Field Summary

Modifier and TypeField and Description
public String
alias

the alias for the attribute used in a ShaderProgram

public final boolean
normalized

For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)

public final int
numComponents

the number of components this attribute has

public int
offset

the offset of this attribute in bytes, don't change this!

public final int
type

the OpenGL type of each component, e.g. GL20#GL_FLOAT or GL20#GL_UNSIGNED_BYTE

public int
unit

optional unit/index specifier, used for texture coordinates and bone weights

public final int
usage

The attribute Usage, used for identification.

private final int

Constructor Summary

AccessConstructor and Description
public
VertexAttribute(int
The attribute Usage, used to select the type and for identification.
usage
,
int
the number of components of this attribute, must be between 1 and 4.
numComponents
,
String
the alias used in a shader for this attribute. Can be changed after construction.
alias
)

Constructs a new VertexAttribute.

public
VertexAttribute(int
The attribute Usage, used to select the type and for identification.
usage
,
int
the number of components of this attribute, must be between 1 and 4.
numComponents
,
String
the alias used in a shader for this attribute. Can be changed after construction.
alias
,
int
Optional unit/index specifier, used for texture coordinates and bone weights
unit
)

Constructs a new VertexAttribute.

public
VertexAttribute(int
The attribute Usage, used for identification.
usage
,
int
the number of components of this attribute, must be between 1 and 4.
numComponents
,
int
the OpenGL type of each component, e.g. GL20#GL_FLOAT or GL20#GL_UNSIGNED_BYTE. Since Mesh stores vertex data in 32bit floats, the total size of this attribute (type size times number of components) must be a multiple of four.
type
,
boolean
For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)
normalized
,
String
The alias used in a shader for this attribute. Can be changed after construction.
alias
)

Constructs a new VertexAttribute.

public
VertexAttribute(int
The attribute Usage, used for identification.
usage
,
int
the number of components of this attribute, must be between 1 and 4.
numComponents
,
int
the OpenGL type of each component, e.g. GL20#GL_FLOAT or GL20#GL_UNSIGNED_BYTE. Since Mesh stores vertex data in 32bit floats, the total size of this attribute (type size times number of components) must be a multiple of four bytes.
type
,
boolean
For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)
normalized
,
String
The alias used in a shader for this attribute. Can be changed after construction.
alias
,
int
Optional unit/index specifier, used for texture coordinates and bone weights
unit
)

Constructs a new VertexAttribute.

Method Summary

Modifier and TypeMethod and Description
public static VertexAttribute
public static VertexAttribute
BoneWeight(int unit)

public static VertexAttribute
public static VertexAttribute
public VertexAttribute
copy()

Returns: A copy of this VertexAttribute with the same parameters.

public boolean
equals(final Object obj)

Overrides java.lang.Object.equals.

Tests to determine if the passed object was created with the same parameters

public boolean
equals(final VertexAttribute other)

public int
getKey()

Returns: A unique number specifying the usage index (3 MSB) and unit (1 LSB).

public int
getSizeInBytes()

Returns: How many bytes this attribute uses.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static VertexAttribute
public static VertexAttribute
public static VertexAttribute
public static VertexAttribute
TexCoords(int unit)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

aliasback to summary
public String alias

the alias for the attribute used in a ShaderProgram

normalizedback to summary
public final boolean normalized

For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)

numComponentsback to summary
public final int numComponents

the number of components this attribute has

offsetback to summary
public int offset

the offset of this attribute in bytes, don't change this!

typeback to summary
public final int type

the OpenGL type of each component, e.g. GL20#GL_FLOAT or GL20#GL_UNSIGNED_BYTE

unitback to summary
public int unit

optional unit/index specifier, used for texture coordinates and bone weights

usageback to summary
public final int usage

The attribute Usage, used for identification.

usageIndexback to summary
private final int usageIndex

Constructor Detail

VertexAttributeback to summary
public VertexAttribute(int usage, int numComponents, String alias)

Constructs a new VertexAttribute. The GL data type is automatically selected based on the usage.

Parameters
usage:int

The attribute Usage, used to select the type and for identification.

numComponents:int

the number of components of this attribute, must be between 1 and 4.

alias:String

the alias used in a shader for this attribute. Can be changed after construction.

VertexAttributeback to summary
public VertexAttribute(int usage, int numComponents, String alias, int unit)

Constructs a new VertexAttribute. The GL data type is automatically selected based on the usage.

Parameters
usage:int

The attribute Usage, used to select the type and for identification.

numComponents:int

the number of components of this attribute, must be between 1 and 4.

alias:String

the alias used in a shader for this attribute. Can be changed after construction.

unit:int

Optional unit/index specifier, used for texture coordinates and bone weights

VertexAttributeback to summary
public VertexAttribute(int usage, int numComponents, int type, boolean normalized, String alias)

Constructs a new VertexAttribute.

Parameters
usage:int

The attribute Usage, used for identification.

numComponents:int

the number of components of this attribute, must be between 1 and 4.

type:int

the OpenGL type of each component, e.g. GL20#GL_FLOAT or GL20#GL_UNSIGNED_BYTE. Since Mesh stores vertex data in 32bit floats, the total size of this attribute (type size times number of components) must be a multiple of four.

normalized:boolean

For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)

alias:String

The alias used in a shader for this attribute. Can be changed after construction.

VertexAttributeback to summary
public VertexAttribute(int usage, int numComponents, int type, boolean normalized, String alias, int unit)

Constructs a new VertexAttribute.

Parameters
usage:int

The attribute Usage, used for identification.

numComponents:int

the number of components of this attribute, must be between 1 and 4.

type:int

the OpenGL type of each component, e.g. GL20#GL_FLOAT or GL20#GL_UNSIGNED_BYTE. Since Mesh stores vertex data in 32bit floats, the total size of this attribute (type size times number of components) must be a multiple of four bytes.

normalized:boolean

For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)

alias:String

The alias used in a shader for this attribute. Can be changed after construction.

unit:int

Optional unit/index specifier, used for texture coordinates and bone weights

Method Detail

Binormalback to summary
public static VertexAttribute Binormal()
BoneWeightback to summary
public static VertexAttribute BoneWeight(int unit)
ColorPackedback to summary
public static VertexAttribute ColorPacked()
ColorUnpackedback to summary
public static VertexAttribute ColorUnpacked()
copyback to summary
public VertexAttribute copy()
Returns:VertexAttribute

A copy of this VertexAttribute with the same parameters. The offset is not copied and must be recalculated, as is typically done by the VertexAttributes that owns the VertexAttribute.

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Tests to determine if the passed object was created with the same parameters

Annotations
@Override
equalsback to summary
public boolean equals(final VertexAttribute other)
getKeyback to summary
public int getKey()
Returns:int

A unique number specifying the usage index (3 MSB) and unit (1 LSB).

getSizeInBytesback to summary
public int getSizeInBytes()
Returns:int

How many bytes this attribute uses.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
Normalback to summary
public static VertexAttribute Normal()
Positionback to summary
public static VertexAttribute Position()
Tangentback to summary
public static VertexAttribute Tangent()
TexCoordsback to summary
public static VertexAttribute TexCoords(int unit)