Sign in to follow this  

glGetUniformLocation strange returning result

Recommended Posts

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 this post

Link to post
Share on other sites
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 this post

Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this