vertexAttrib commands

The vertexAttrib family of commands set a default vertex element that will be used for all attribute input when a vertex attribute is disabled.

The vertexAttrib family of commands (vertextAttrib1f, vertexAttrib1fv, etc.) allow applications to pass generic vertex attributes in numbered locations.

Generic vertex attributes are defined as four-component values that are organized into an array. The first entry of this array is numbered 0, and the size of the array is specified by the implementation-dependent MAX_VERTEX_ATTRIBS value (returned by getParameter). Individual elements of this array can be modified with one of the vertexAttrib commands that specifies the index of the element to be modified and a value for that element.

These commands can be used to specify one, two, three, or all four components of the generic vertex attribute specified by the indx parameter. A 1 in the name of the command (as in vertexAttrib1f) indicates that only one value is passed, and it will be used to modify the first component of the generic vertex attribute. The second and third components will be set to 0, and the fourth component will be set to 1. Similarly, a 2 in the name of the command indicates that values are provided for the first two components, the third component will be set to 0, and the fourth component will be set to 1. A 3 in the name of the command indicates that values are provided for the first three components and the fourth component will be set to 1, whereas a 4 in the name indicates that values are provided for all four components.

The letter f (as in vertexAttrib1f) indicates that the arguments are of type float. When v is appended to the name (as in vertexAttrib3fv), the commands can receive a float array object (see Typed Arrays).

A user-defined attribute variable declared in a vertex shader can be bound to a generic attribute index by calling bindAttribLocation. This allows an application to use descriptive variable names in a vertex shader. A subsequent change to the specified generic vertex attribute will be immediately reflected as a change to the corresponding attribute variable in the vertex shader.

The binding between a generic vertex attribute index and a user-defined attribute variable in a vertex shader is part of the state of a program object, but the current value of the generic vertex attribute is not. The value of each generic vertex attribute is part of current state and it is maintained even if a different program object is used.

A software application may freely modify generic vertex attributes that are not bound to a named vertex shader attribute variable. These values are simply maintained as part of current state and will not be accessed by the vertex shader. If a generic vertex attribute bound to an attribute variable in a vertex shader is not updated while the vertex shader is executing, the vertex shader will repeatedly use the current value for the generic vertex attribute.

Be aware that:

  • Generic vertex attributes can be updated at any time.
  • It is possible for an application to bind more than one attribute name to the same generic vertex attribute index - this is known as aliasing. Internet Explorer 11 does not perform error checking to detect aliasing and assumes that aliasing never occurs. In other words, aliasing is not allowed in IE11.

Note  The INVALID_VALUE error is generated if indx is greater than or equal to MAX_VERTEX_ATTRIBS.

In this section

TopicDescription

vertexAttrib1f

This command allows an application to pass generic vertex attributes in numbered locations.

vertexAttrib1fv

This command allows an application to pass generic vertex attributes in numbered locations.

vertexAttrib2f

This command allows an application to pass generic vertex attributes in numbered locations.

vertexAttrib2fv

This command allows an application to pass generic vertex attributes in numbered locations.

vertexAttrib3f

This command allows an application to pass generic vertex attributes in numbered locations.

vertexAttrib3fv

This command allows an application to pass generic vertex attributes in numbered locations.

vertexAttrib4f

This command allows an application to pass generic vertex attributes in numbered locations.

vertexAttrib4fv

This command allows an application to pass generic vertex attributes in numbered locations.

 

Related topics

enableVertexAttribArray

 

 

Show:
© 2014 Microsoft