Solved
I feel dumb now. 2 minutes after opening the thread I managed to fix the problem after working on this for a whole day.
For anyone who is just as clueless as I was: I had to bind the attribute location. Or at least this solved my problem. :doh:
I was toying around with shaders recently but I got into a problem I just can not fix myself.
I have one very simple shader program:
Vertex-Shader
varying vec4 v_color;
void main()
{
v_color = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Fragment-Shader
varying vec4 v_color;
void main()
{
gl_FragColor = v_color;
}
And I have a VBO with an Array-Buffer like this:
[ 53.0, 353.0, 1.0, 1.0,
1.0, 0.5, 0.0, 1.0,
654.0, 31.0, 1.0, 1.0,
1.0, 0.5, 0.0, 1.0 ]
and an Element-Array-Buffer like this: [0, 1]
I draw with glDrawElements(GL_LINES, 2, GL_INT, 0);
And I have this code to set the attribute pointers:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4, GL_FLOAT, 32, 0);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_FLOAT, 32, 16);
And everything works. I see a line being drawn on the screen.
But now I wanted to toy around and change the shader slightly:
Vertex-Shader
attribute vec4 test;
varying vec4 v_color;
void main()
{
v_color = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * test;
}
Fragment-Shader
varying vec4 v_color;
void main()
{
gl_FragColor = v_color;
}
The VBO and the buffers still look the same but I changed the pointers to this:
int id = glGetAttribLocation(pId, "test");
glEnableVertexAttribArray(id);
glVertexAttribPointer(id, 4, GL_FLOAT, GL_FALSE, 32, 0);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_FLOAT, 32, 16);
But nothing is drawn anymore.
I know I did something wrong, but I dont know what. I am probably using the custom vertex attribute incorrectly I guess.
Thank you very much for your help.