I’ve found a problem in a program and I’m not sure whether it’s a bug or I did something wrong. So if you’re familiar with VBO here’s your chance to help me
When I use a vertex program with generic attributes and VBO to draw something, then use standard vertex arrays and draw something again the latter won’t be displayed.
To make it simple I’ve created a minimal app that shows my problem: I’m just drawing two quads. The first with VBO and a vertex program using generic attributes:
glBindProgramARB(GL_VERTEX_PROGRAM_ARB,vertexProgAttrib);
glEnable(GL_VERTEX_PROGRAM_ARB);glEnableVertexAttribArrayARB(0);
glEnableVertexAttribArrayARB(3);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboHandle);glVertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (char*)0);
glVertexAttribPointerARB(3, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (char*)12);glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, &indices[0] );
glDisableVertexAttribArrayARB(0);
glDisableVertexAttribArrayARB(3);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);glDisable(GL_VERTEX_PROGRAM_ARB);
The second one goes like that:
glPushMatrix();
glTranslatef(1.5,1.5,0);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer( 3,GL_FLOAT, sizeof(Vertex), &verts[0].x );
glColorPointer( 3,GL_FLOAT, sizeof(Vertex), &verts[0].r );
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, &indices[0] );
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glPopMatrix();
This quad won’t be shown on the screen!
I’ve only seen that issue on my GeForce 3 Ti with latest official detonators and the inofficial 44.65. The code runs fine on my ATI M9.
The full source code is available on http://home.augustakom.net/as120108/VBOBug.zip . You can use the key ‘v’ to switch between using VBO / standard vertex arrays for the first quad and ‘a’ to switch between generic attributes and conventional attributes. You can see the current mode in the console window (But make sure you press the keys in the app window…)
Thanks!