GLSL glGetUniformLocationARB Returns -1

This topic is 3646 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm working on a tool and a section of my code that is used for game world previewing generates an invalid return value when I call glGetUniformLocation. The return value that I get is -1, which from what I understand means that the function could not find the value for the uniform I'm looking for or that the uniform I am looking for is not used inside of the shader. That would be perfect if it were true that uniform could not be found, but I can see it very well in my vertex shader and it is in use in the shader. Also to make sure that the correct shader is being loaded I checked my debug data to make sure that the uniform was being loaded at runtime. The correct shaders are being loaded and the debug data shows that the uniform is in there and is correct. Below I have some code snippets: Vertex Shader Code:
uniform vec3 Light, Eye;

void main()
{
// Unnormalized vector to light.
vec3 L = Light - gl_Vertex.xyz;

// Unnormalized vector to eye.
vec3 V = Eye - gl_Vertex.xyz;


Application Code:
shader->TurnOn();


The shader class used in the above code has been used in other applications and should work fine, however I will test this to see if it is in fact true. If my question is not clear right now, it is that I would like to know why I am getting a -1 return value from the glUniformLocation function. If anyone knows why this might be the case, I will get very grateful. Thank you in advance for any and all help.

Share on other sites
Have you checked the shader log?

Share on other sites
Thanks for the reply NisseBosseLasse. Where can I find the shader log?

Share on other sites
Then glGetUniformLoc.

You also need to make sure that your shader compiles, which it looks like your shader probably isnt compiling unless you have more to it that u omitted.

Share on other sites
I found some errors and here they are:

(31) : error C0000: syntax error, unexpected \$undefined at token "<undefined>"
(31) : error C0501: type name expected at token "<undefined>"

I have no idea what these mean. Does anyone know what they might mean? They came from the vertex shader.

Also I checked the validity of the vertex shader in GLSL Validation and everything seems to be fine with the shader so the problem must be with the application itself.

I think I should also mention that I'm using MFC for my application

Share on other sites
Alright I got it working. The problem I believe was my OpenGL device context. I was not using the correct one. Thank you to everyone that posted to help me with this issue.

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×