PDA

View Full Version : Getting Uniform Locations



Dtag
12-31-2003, 04: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?

PanzerSchreck
12-31-2003, 05: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.

Dtag
12-31-2003, 05: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).]

PanzerSchreck
12-31-2003, 05: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 :


glUseProgramObjectARB(ProgramObject);
glGetUniformLocationARB(ProgramObject, ...);

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

[VP]
//VertexProgramHere
[FP]
//FragmentProgramHere
EOF http://www.opengl.org/discussion_boards/ubb/smile.gif

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

Dtag
12-31-2003, 08: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