I just tried to render the first redbook example ( the white Quad ) by using VBOs.
It works fine with immediate mode and vertex arrays.
But when using VBOs the screen stays black. I think i must have missed something important.
init:
unsigned int bufIds[2];
glGenBuffers( 2, bufIds );
GLfloat vertices[] = {
0.25, 0.25, 0.0,
0.75, 0.25, 0.0,
0.75, 0.75, 0.0,
0.25, 0.75, 0.0
};
glBindBuffer( GL_ARRAY_BUFFER, bufIds[0] );
glBufferData( GL_ARRAY_BUFFER, 12, vertices, GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glClearColor( 0, 0, 0, 1 );
glColor3f( 1, 1, 1 );
glOrtho( 0.0, 1.0, 0.0, 1.0, -1.0, 1.0 );
renderloop for VBO (not working):
glClear( GL_COLOR_BUFFER_BIT );
glEnableClientState( GL_VERTEX_ARRAY );
glBindBuffer( GL_ARRAY_BUFFER, bufIds[0] );
glVertexPointer( 3, GL_FLOAT, 0, 0 );
glDrawArrays( GL_QUADS, 0, 12 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glDisableClientState( GL_VERTEX_ARRAY );
renderloop for vertex arrays (working):
glClear( GL_COLOR_BUFFER_BIT );
glEnableClientState( GL_VERTEX_ARRAY );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glVertexPointer( 3, GL_FLOAT, 0, vertices );
glDrawArrays( GL_QUADS, 0, 12 );
glDisableClientState( GL_VERTEX_ARRAY );