PDA

View Full Version : glUniform values are preserved when shader is uninstalled?



Fran1975
01-02-2015, 11:52 AM
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!

Alfonse Reinheart
01-02-2015, 01:35 PM
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).

arekkusu
01-02-2015, 02:55 PM
Except for subroutine uniforms, which are reset every time.

Alfonse Reinheart
01-02-2015, 03:05 PM
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...