I have a problem while getting an uniform from a shader. The line:
int u = GL20.glGetUniformLocation(program, uniform);
is used to check if the uniform defined by the string uniform is in the shader.
Here is an example check code:
System.out.println(GL20.glGetUniformLocation(1, "transformationMatrix")==0);
System.out.println(GL20.glGetUniformLocation(1, "projectionMatrix")==0);
And the result:
false
true
Here it comes the weird thing: The vertex shader code is the following:
#version 330
layout (location = 0) in vec3 pos;
layout (location = 1) in vec3 tex;
layout (location = 2) in vec3 nor;
layout (location = 3) in vec3 col;
uniform mat4 projectionMatrix;
uniform mat4 transformationMatrix;
out vec3 normal;
void main(){
normal = nor;
gl_Position = projectionMatrix * vec4(pos, 1);
}
I have tested renaming the uniform, removing the other one, but the only one uniform OpenGL seems to recognize is the "projectionMatrix" one.
Enviroment: Java with lwjgl OpenGl in linux with mesa 10.4.0 (Doesn't work on Windows either)