glUniform values are preserved when shader is uninstalled?

Hi everybody,
When a shader is uninstalled and installed later. Is necessary rewrite the Uniform values?
P.e.

GLuint program1, program2;
GLuint uniform1, uniform2;

// program1, program2 with valid values

glUseProgram(program1);
glUniform1f(uniform1, 54.34);

glUseProgram(program2);
glUniform1f(uniform2, 23.56);

glUseProgram(program1);
// uniform1 == 54.34??

Thanks!

When you say “install”, what you really mean is “use” or (more accurately, but not seen in the function call) “bind”. And yes, uniform values are state stored in program objects, so their contents are preserved when those objects are unbound (and later rebound).

Except for subroutine uniforms, which are reset every time.

Which is (one reason) why they [don’t use](Runtime selection) glUniform/glProgramUniform. Also, it’s why they shouldn’t have been called “subroutine uniforms” to begin with…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.