Graphics Reference
In-Depth Information
Vertex attribute data can be specified for each vertex using a vertex array,
or a constant value can be used for all vertices of a primitive.
All OpenGL ES 3.0 implementations must support a minimum of
16 vertex attributes. An application can query the exact number of
vertex attributes that are supported by a particular implementation. The
following code shows how an application can query the number of vertex
attributes an implementation actually supports:
GLint maxVertexAttribs; // n will be >= 16
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
A constant vertex attribute is the same for all vertices of a primitive, so
only one value needs to be specified for all the vertices of a primitive. It is
specified using any of the following functions:
void
glVertexAttriblf
(GLuint
index
, GLfloat
x
);
void
glVertexAttrib2f
(GLuint
index
, GLfloat
x
, GLfloat
y
);
void
glVertexAttrib3f
(GLuint
index
, GLfloat
x
, GLfloat
y
,
GLfloat
z
);
void
glVertexAttrib4f
(GLuint
index
, GLfloat
x
, GLfloat
y
,
GLfloat
z
, GLfloat
w
);
void
glVertexAttriblfv
(GLuint
index
, const GLfloat *
values
);
void
glVertexAttrib2fv
(GLuint
index
, const GLfloat *
values
);
void
glVertexAttrib3fv
(GLuint
index
, const GLfloat *
values
);
void
glVertexAttrib4fv
(GLuint
index
, const GLfloat *
values
);
The
glVertexAttrib*
commands are used to load the generic vertex
attribute specified by
index.
The functions
glVertexAttriblf
and
glVertexAttriblfv
load (
x
, 0.0, 0.0, 1.0) into the generic vertex attribute.
glVertexAttrib2f
and
glVertexAttrib2fv
load (
x
,
y
, 0.0, 1.0) into the
generic vertex attribute.
glVertexAttrib3f
and
glVertexAttrib3fv
load (
x
,
y
,
z
, 1.0) into the generic vertex attribute.
glVertexAttrib4f
and
glVertexAttrib4fv
load (
x
,
y
,
z
,
w
) into the generic vertex attribute. In
practice, constant vertex attributes provide equivalent functionality to
using a scalar/vector uniform, and using either is an acceptable choice.
Vertex arrays specify attribute data per vertex and are buffers stored in the
application's address space (what OpenGL ES calls the
client
space). They