glGetUniformLocation strange returning result

Recommended Posts

VerMan    116
Hello, this is happening to me:
//fragment shader
uniform tex2D texture;
uniform tex2D texture2;
...


But when i try to get the uniform locations i get something like this:
t1 = glGetUniformLocation(program,"texture"); //returns 0
t2 = glGetUniformLocation(program,"texture2"); //returns -1!!


why the -1? if the uniform is there? if i change the names, sometimes i just get -1 always... wtf? is driving me crazy. Have you ever gone through this?

Share on other sites
karwosts    840
Are you actually using texture2 for anything in your shader?

If it does not directly effect the output, it will be optimized out by GLSL compiler, and thus you cannot get the location anymore.

Share on other sites
VerMan    116
uhmm ineresting... sometimes i se it, sometimes i don't since i'm doing some testing...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account