Shaders & programsGL 2.0
glGetProgramiv
Queries a property of a program — mainly whether it linked.
Part of the family glGet*
Signature
void glGetProgramiv(GLuint program, GLenum pname, GLint *params);
How it works
The program-side twin of glGetShaderiv. After glLinkProgram, ask for GL_LINK_STATUS: linking fails when stages do not fit together, for example a fragment shader input with no matching vertex shader output, or a type that differs between the two. If it failed, glGetProgramInfoLog says why.
Other useful questions: GL_ACTIVE_UNIFORMS and GL_ACTIVE_ATTRIBUTES list what survived compilation (unused variables are removed).
Parameters
programGLuint
Program to query.
pnameGLenum
Which property.
Common values
- GL_LINK_STATUS
- GL_TRUE if the last link succeeded.
- GL_INFO_LOG_LENGTH
- Size of the link log.
- GL_ACTIVE_UNIFORMS
- Number of uniforms the compiler kept.
- GL_VALIDATE_STATUS
- Result of glValidateProgram.
- GL_COMPUTE_WORK_GROUP_SIZE
- local_size of a compute program (3 ints).
paramsGLint *
Where the result is written.
Example
example.cpp
1GLint ok;
2glGetProgramiv(program, GL_LINK_STATUS, &ok);