View Full Version : Getting Uniform Locations

12-31-2003, 03:34 AM
Hi... ive created some extremely simple GLSL shader. It links and compiles without any glError/Linker Error/Compile error for me. The problem is that glGetUniformLocationARB always returns -1, even tough the variables definately exist in the shader i passed to GL. Any ideas?

12-31-2003, 04:06 AM
Since there isn't much room for errors within glGetUniformLocationARB, only two things can happen : You didn't wrote the parameter's name casesensitive (e.g. texture0 instead of Texture0) or you have specified the wrong programobject.

12-31-2003, 04:13 AM
Well i wrote the variable names correctly. As my program handle im getting a strange value ( hProgram==0x80000001 ) But commands like linking etc are obviously working because if i create some errors in the source, they are reported correctly. Also theres no glError being created when i call glCreateProgramObjectARB

[This message has been edited by Dtag (edited 12-31-2003).]

12-31-2003, 04:31 AM
Are you sure that the programobject to which those parameters belong is the current? I've noticed that it won't work if you pass parameters for PO1 if e.g. PO2 is bound, so make sure you make something like this :

glGetUniformLocationARB(ProgramObject, ...);

12-31-2003, 04:41 AM
Yep im quite sure about that.
You can see my code here
The uniform location is requested at the very end if linked is true...
Just for clarification: my shader files look like this:

EOF http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Dtag (edited 12-31-2003).]

12-31-2003, 07:45 AM
Hmmm i just fixed the bug... It was because i didnt actually USE the uniform variables in the shader i just declared them ... the compiler obviously optimized them away