uniform location problem

hello,

i´m having some problems with a simple calculation in the vertex shader suppose this:

uniform vec4 a;
uniform vec4 b;
uniform vec4 c;

varying vec4 result;

void main(){

// …the usual stuff here…then
res = a + b + c ;

}

and for some reason that i don´t know why i can´t get the uniform location for any of those uniforms…how can i work around this !!! when ever i try to get the locations i always get “-1”…so no locations is compiled…

It can return -1 if the variables have been optimized out by the GLSL compiler.

res = a + b + c ;

the was no ‘res’ declared

that was it…LOL…i´ve been looking for ages and i couldn´t see it…Thanks!!!

I guess you are not checking shaders compiling & linking for errors.
You should check to avoid this kind of problems :slight_smile:

yeah i now , i am checking for erros,the thing was that in the middle of the code i wasn´t using one of the uniforms and it was the cause for the location problem…

Thanks

Incidentally you can group uniforms in a buffer backed block, and in so doing any single uniform referenced will drag in the whole enchilada. ARB_uniform_buffer_object is a core feature of OpenGL 3.1.

hello Brolingstanz,

i haven´t read the Opengl 3.0 , 3.1 & 3.2 spec , i´m still using the old 2.0, and as soon as i finish this opengl project i´m in, i will go to 3.1 asap :slight_smile: , then i will have to evaluate every object made for openGL 2.0 and make it 3.1 usable, like Fbo and so on…

That feature seems pretty cool, can´t wait to learn about the new spec, and so to use them :smiley: