I'm developping an OpenGLes 3.0 app with Java and I started writing the shader code. For some reason, it seems to mix up the attributes data locations and I don't understand why. Here's the code :
Vertex shader:
#version 300 es
precision mediump float;
in vec3 position;
in vec2 uv;
in vec3 normal;
uniform mat4 transform;
uniform mat4 projection;
out f_norm;
void main(){
//f_norm = normal;
gl_Position = projection*transform*vec4(position,1.0);
}
Fragment Shader :
#version 300 es
precision mediump float;
in f_norm;
out vec4 Fragment;
void main(){
Fragment = vec4(1.0);
}
I bind the VBOs using these lines :
GLES30.glBindAttribLocation(ProgramID,0,"position");
GLES30.glBindAttribLocation(ProgramID,1,"uv");
GLES30.glBindAttribLocation(ProgramID,2,"normal");
In the current form, the program works just fine, but if I uncomment this line : f_norm = normal
, in the vertex shader, suddenly it uses uv coordinates as positions, even though they aren't used.
I know the data and the data mapping is fine : it works when I comment out the above line.
I know the binding is happening : it is very explicitly called, with the right values, when I check with the debugger.
I made sure that all the VBOs are properly enable and disable before and after the draw call.
I found an easy workaround ( specify layout(location = <VBO>)
in front of the variables), but I'd like to know what's happening here, to get a more permanent fix.