(note this question is closely related to this one however I didn't fully understand the accepted answer)
To support videocards in laptops I have to rewrite my GLSL 330 shaders to GLSL 130. I'm trying to do this but somehow I don't get vertex attributes to work properly.
My 330 shaders look like this:
#version 330
layout(location = 0) in vec4 position;
layout(location = 3) in vec4 color;
smooth out vec4 theColor;
void main()
{
gl_Position = position;
theColor = color;
}
Now this explicit layout is not allowed in GLSL 130 so I referenced this page to see what the default layouts for some values would be. As you can see position should be the 0th vertex attribute and color should be the 3rd vertex attribute. Because this is a test case I had already configured my explicit layouts in the same way, which worked, so I now simply rewrote my shader to this and expected it to work:
#version 130
smooth out vec4 theColor;
void main()
{
gl_Position = gl_Vertex;
theColor = gl_Color;
}
However this doesn't work, the value of gl_Color is always (1,1,1,1). So how should I pass multiple vertex attributes to my GLSL 130 shaders?
For reference, this is how I set my vertex buffer object and attributes (I've just adapted this tutorial to JAVA+JOGL)
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vertex_buffer_id);
gl.glEnableVertexAttribArray(0);
gl.glEnableVertexAttribArray(3);
gl.glVertexAttribPointer(0, 4 , GL3.GL_FLOAT, false, 0, 0);
gl.glVertexAttribPointer(3, 4, GL3.GL_FLOAT, false, 0, 4*4*4);
gl.glDrawArrays(GL3.GL_TRIANGLE_STRIP, 0, 4);
gl.glDisableVertexAttribArray(0);
gl.glDisableVertexAttribArray(3);
EDIT
I solved the problem by querying for the layout locations of position an color using glGetAttribLocation however I still don't understand why the 'hardcoded' values like gl_Color didn't work, can't I upload data in there as normal? Shouldn't they be used?