View Full Version : glGetAttribLocation and a -1 return value?
02-10-2009, 04:11 AM
I am at my minds end, I have no errors when checking my code with GL's built in calls, and I am using the vertex attribute in my VS... What else would cause me to get a -1? I am using GLUT to do some test runs on my new shader lib, and the same code works in my engine. The shader runs and shows a textured surface, but the values are wrong, and gDebugger throws the error saying that glEnableVertexAttribArray() has a wrong value...
02-10-2009, 04:45 AM
might be that your attrib variable isn't properly used in your shader thus might be skipped because of no use. happend to me because of exactly that but with uniform variables.
02-10-2009, 11:32 AM
I doubt it as render monkey says its compiles with success. The code in the shader is the same as my engines code and that returns a value other than -1...
02-10-2009, 01:14 PM
Did you test your code on the same hardware for your engine and your new shader lib?
If you did, it seems that your problem comes from your opengl program. I advise you to use the GetActiveAttrib function to get the list of all active attributes and see if everything is fine.
Are you sure that Opengl did not threw any error? Shader program is succesfully linked?
I am not sure to understand you about "GL's built in calls", can you elaborate a bit more?
02-10-2009, 04:40 PM
I checked and I only have two active, and those are gl_Vertex and gl_MultiTexCoord0... I should have 5
tangent, bitangent, gl_Normal doesn't even show up ....
attribute vec3 Tangent, BiTangent;
vec3 t = gl_NormalMatrix * Tangent;
vec3 b = gl_NormalMatrix * BiTangent;
vec3 n = gl_NormalMatrix * gl_Normal;
gl_TexCoord = gl_MultiTexCoord0;
gl_Position = ftransform();
02-10-2009, 06:34 PM
The only place I have seen this happen before is when I got the order of GLSL compiling, linking, binding and so on messed up. Is that any help?
02-10-2009, 09:22 PM
Hi scratt, nah, I have kept the code in order from my other code base, which works.
02-11-2009, 01:35 AM
_NK47 already explained your problem.
In your vertex shader code you posted I do not see how t, b and n variables are used - therefore they are optimized out. That is why Tangent, BiTangent and gl_Normal also is not needed in shader - so they are also optimized out. This is normal for GLSL. Same thing happens also with uniforms - if you do not use them or some other variables (which are calculated from these uniforms) then uniforms are optimized out.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.