Function familiesfamily
glProgramUniform*
The glUniform family with the program as first argument: no glUseProgram needed (GL 4.1).
Signature
void glProgramUniform{1|2|3|4}{f|i|ui}[v](GLuint program, GLint location, …);
How it works
Every glUniform* has a glProgramUniform* twin with the same suffixes and one extra first parameter, the program. It sets the value directly in that program, whichever program is in use, the same idea as Direct State Access. Mixing the two families is fine: a uniform's value lives in its program, however it was set.
Reading the name
- 1f, 3fv, Matrix4fv…
- Read exactly like glUniform*: count, type, v for pointer.
Functions in this family
Example
example.cpp
1glProgramUniform1f(prog, glGetUniformLocation(prog, "uTime"), t);
2glProgramUniformMatrix4fv(prog, locModel, 1, GL_FALSE, glm::value_ptr(model));