This is how I’m setting up my VBO:
// Generate And Bind The Vertex Buffer
glGenBuffers( 1, &m_vbo_verts_name ); // Get A Valid Name
glBindBuffer( GL_ARRAY_BUFFER, m_vbo_verts_name ); // Bind The Buffer
glBufferData( GL_ARRAY_BUFFER, m_faces.size()*9*sizeof(float), m_vbo_vert, GL_STATIC_DRAW );
I’m simply generating the buffers here. Basically I know I have 9 float values per face. I have the flowing struct called VBO_vert:
struct VBO_vert {
float x;
float y;
float z;
};
So basically I have a certain number of faces and the size of the buffer is just going to be 9 floats (3 vertices per face). I’m going to have redundant vertices (faces sharing vertices but thats fine.
Anyways, that gets run only one time in my Mesh initialization.
Then my draw code:
glVertexPointer(3, GL_FLOAT, 0, m_vbo_vert);
glTexCoordPointer(2, GL_FLOAT, 0, m_vbo_texture);
glNormalPointer(GL_FLOAT, 0, m_vbo_normal);
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glDrawArrays(GL_TRIANGLES,0, m_faces.size()*9);
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
I know my drawing is okay since my old draw without VBO works. I need to use VBO since I’m going to need to pass in more information per vertex and I’d like to use VBO’s. Any ideas what I’m doing wrong?