Graphics Reference
In-Depth Information
them together into a single four-component attribute instead of declaring
them as individual vertex attributes in the vertex shader.
Variables declared as vertex attributes in a vertex shader are read-only
variables and cannot be modified. The following code should cause a
compilation error:
in vec4 a_pos;
uniform vec4 u_v;
void main()
{
a_pos = u_v; <--- cannot assign to a_pos as it is read-only
}
An attribute can be declared inside a vertex shader—but if it is not
used, then it is not considered active and does not count against the
limit. If the number of attributes used in a vertex shader is greater than
GL_MAX_VERTEX_ATTRIBS , the vertex shader will fail to link.
Once a program has been successfully linked, we may need to find out
the number of active vertex attributes used by the vertex shader attached
to this program. Note that this step is necessary only if you are not using
input layout qualifiers for attributes. In OpenGL ES 3.0, it is recommended
that you use layout qualifiers; thus you will not need to query this
information after the fact. However, for completeness, the following line
of code shows how to get the number of active vertex attributes:
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &numActiveAttribs);
A detailed description of glGetProgramiv is given in Chapter 4, “Shaders
and Programs.”
The list of active vertex attributes used by a program and their data types
can be queried using the glGetActiveAttrib command.
void glGetActiveAttrib (GLuint program , GLuint index ,
GLsizei bufsize , GLsizei * length ,
GLenum * type , GLint * size ,
GLchar * name )
program name of a program object that was successfully linked
previously.
 
 
Search WWH ::




Custom Search