I’m on Windows 7 and using VC++ 2010.
I’m trying to load and render a mesh using VBOs. I’ve checked that all the indices and vertex values are valid, and I don’t get any crashes or errors from OpenGL.
Nothing is showing up on the screen…
In this model there are 36 indices and 24 verticies, just a simple cube.
vbo and indexVbo are both valid values. (vbo = 1, indexVbo = 2)
I’m checking glGetError in a loop untill it returns GL_NO_ERROR at the end of each frame and it always returns GL_NO_ERROR.
If you need any more information just ask.
(I have a valid window/opengl context/dc)
my vertex_t structure looks like this:
typedef struct
{
float location[3]; // 0
float st[3]; // 12
float normal[3]; // 24
float color[4]; // 36
} vertex_t;
this is how I load it:
glGenBuffers( 1, &vbo );
glBindBuffer( GL_ARRAY_BUFFER, vbo );
glBufferData( GL_ARRAY_BUFFER, sizeof( vertex_t ) * numVerts, NULL, GL_STATIC_DRAW );
glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof( vertex_t ) * numVerts, vertList );
glTexCoordPointer( 3, GL_FLOAT, sizeof( vertex_t ), 12 );
glNormalPointer( GL_FLOAT, sizeof( vertex_t ), 24 );
glColorPointer( 4, GL_FLOAT, sizeof( vertex_t ), 36 );
glVertexPointer( 3, GL_FLOAT, sizeof( vertex_t ), 0 );
glGenBuffers( 1, &indexVbo );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, indexVbo );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, numIndices * sizeof( byte ), indexList, GL_STATIC_DRAW );
this is how I render it:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 45.0, (double)1024 / (double)768, 5.0, 9999.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -25.0f );
glBindBuffer( GL_ARRAY_BUFFER, vbo );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, indexVbo );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glEnableClientState( GL_VERTEX_ARRAY );
glTexCoordPointer( 3, GL_FLOAT, sizeof( vertex_t ), 12 );
glNormalPointer( GL_FLOAT, sizeof( vertex_t ), 24 );
glColorPointer( 4, GL_FLOAT, sizeof( vertex_t ), 36 );
glVertexPointer( 3, GL_FLOAT, sizeof( vertex_t ), 0 );
glDrawElements( GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, NULL );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
SwapBuffers( hdc );