Graphics Reference
In-Depth Information
To check whether a link was successful, you can query for
GL_LINK_
STATUS
. A large number of other queries can also be executed on
program objects. Querying for
GL_ACTIVE_ATTRIBUTES
returns a count
of the number of active attributes in the vertex shader. Querying for
GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
returns the maximum length (in
characters) of the largest attribute name; this information can be used to
determine how much memory to allocate to store attribute name strings.
Likewise,
GL_ACTIVE_UNIFORMS
and
GL_ACTIVE_UNIFORM_MAX_LENGTH
return the number of active uniforms and the maximum length of the
largest uniform name, respectively. The number of shaders attached to
the program object can be queried using
GL_ATTACHED_SHADERS
. The
GL_DELETE_STATUS
query returns whether a program object has been
marked for deletion. As with shader objects, program objects store an info
log, the length of which can be queried for using
GL_INFO_LOG_LENGTH
.
Querying for
GL_TRANSFORM_FEEDBACK_BUFFER_MODE
returns either
GL_SEPARATE_ATTRIBS
or
GL_INTERLEAVED_ATTRIBS
, which is the buffer
mode when transform feedback is active. Queries for
GL_TRANSFORM_
FEEDBACK_VARYINGS
and
GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH
return the number of output variables to capture in transform feedback
mode for the program and the maximum length of the output variable
names, respectively. The transform feedback is described in Chapter 8,
“Vertex Shaders.” The number of uniform blocks for programs containing
active uniforms and the maximum length of the uniform block names can
be queried using
GL_ACTIVE_UNIFORM_BLOCKS
and
GL_ACTIVE_UNIFORM_
BLOCK_MAX_LENGTH
, respectively. Uniform blocks are described in a later
section. Querying for
GL_PROGRAM_BINARY_RETRIEVABLE_HINT
returns a
value indicating whether the binary retrieval hint is currently enabled for
program. Finally, the status of the last validation operation can be queried
for using
GL_VALIDATE_STATUS
. The validation of program objects is
described later in this section.
After linking the program, we next want to get information from the
program info log (particularly if a link failure occurred). Doing so is
similar to getting the info log for shader objects.
void
glGetProgramInfoLog
(GLuint
program
, GLsizei
maxLength
,
GLsizei *
length
,
GLchar *
infoLog
)
program
handle to the program object for which to get information
maxLength
the size of the buffer in which to store the info log
(continues)