Hello guys,
I am working right now with GLSL and trying to get the location of some uniform variables. So far I found out that the glsl compiler makes some optimizations to these variables if they are not in use, i.e. it results in -1 location.
In my case I cannot understand it really because all variables have influence in the result.
This code I have taken from the orange book. The variable “mvpMatrix” has a positive location, all others no. I hope somebody can explain me, where the problem is.
let me guess, ex_color is not used in the fragment shader (or other connected shader like geometry shader). if not, the linker will remove the calculation to ex_color and so the uniforms are unused and will return an invalid location…
Hello again,
With this fragment shader above it doesn’t work. Then I removed this fragment shader, so that I have only one vertex shader and then glsl recognized my uniform variables. The output of the uniform count was 6 and the attribute count was 2 (as expected). So I am a little bit confused… why it is working without the fragment shader?