Since there is no initializer, I expect its initial value to be 0. From the GLSL 1.5 spec:
The link time initial value is either the value of the variable’s initializer, if present, or 0 if no initializer is present.
After linking, I query the value with glGetUniformiv and receive 13 not 0. Furthermore, the if statement in the shader that checks the uniform evaluates to false so it’s as if the value is actually 0 but 13 is returned.
I’ve tried both glGetUniformiv and glGetUniformfv using GLSL 1.1 and 1.5. I am running NVIDIA GeForce 9 on Windows Vista 64-bit with 191.07 drivers. Has anyone experienced anything similar?
I agree that it’s slow but I shadow the value of uniforms to avoid redundantly setting them so I need to query the value once right after linking. I can’t just give it a default value because that would overwrite an initializer in the GLSL code. So I wind up reading the initial value with glGetUniform then immediately setting that same value with glUniform so my shadowed copy is in sync with the driver.
Not sure if this is what you’re talking about or not, but if so, I don’t understand your statement. false would be the initializer, and the value you want. No?
Not sure if this is what you’re talking about or not, but if so, I don’t understand your statement. false would be the initializer, and the value you want. No?
He’s saying that he can’t query the initializer from the OpenGL interface. Obviously yes, if he wanted to, he could parse the shader himself to find out. However, since there’s already a perfectly functional parser in the OpenGL implementation, and a perfectly functional interface to ask these things, there’s no reason for him to do that manually.