I'm trying to implement VBO's into a 2D engine I worte a few years back and I'm not having much luck. I believe I have set the VBO up correctly but I'm getting nothing other than a blank screen.
Any Suggestions?
Here is the initialisation code for the VBOs
this->m_Pos_Verts_ptr = new class clsVert[this->ml_RenderListLength * 4];
this->m_Texture_Verts_ptr = new class clsVert[this->ml_RenderListLength * 4];
this->m_LastPos_Verts_ptr = this->m_Pos_Verts_ptr;
this->m_LastTexture_Verts_ptr = this->m_Texture_Verts_ptr;
for (iL = this->L.begin();
iL != this->L.end();
++ iL)
{
this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X();
this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y() + (*iL)->Get_Height();
++ this->m_LastPos_Verts_ptr;
this->m_LastTexture_Verts_ptr->mf_X = 0.0f;
this->m_LastTexture_Verts_ptr->mf_Y = 1.0f;
++ this->m_LastTexture_Verts_ptr;
this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X() + (*iL)->Get_Width();
this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y() + (*iL)->Get_Height();
++ this->m_LastPos_Verts_ptr;
this->m_LastTexture_Verts_ptr->mf_X = 1.0f;
this->m_LastTexture_Verts_ptr->mf_Y = 1.0f;
++ this->m_LastTexture_Verts_ptr;
this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X() + (*iL)->Get_Width();
this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y();
++ this->m_LastPos_Verts_ptr;
this->m_LastTexture_Verts_ptr->mf_X = 1.0f;
this->m_LastTexture_Verts_ptr->mf_Y = 0.0f;
++ this->m_LastTexture_Verts_ptr;
this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X();
this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y();
++ this->m_LastPos_Verts_ptr;
this->m_LastTexture_Verts_ptr->mf_X = 0.0f;
this->m_LastTexture_Verts_ptr->mf_Y = 0.0f;
++ this->m_LastTexture_Verts_ptr;
}
//9-5-2007 PH Generate and Bind VBO
glGenBuffersARB(1, &ml_VBOID);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, ml_VBOID);
//10-5-2007 Populate vbo
glBufferDataARB( GL_ARRAY_BUFFER_ARB, this->ml_RenderListLength * 4 * sizeof(class clsVert), this->m_Pos_Verts_ptr, GL_STATIC_DRAW_ARB);
// Generate And Bind The Texture Coordinate Buffer
glGenBuffersARB( 1, &this->ml_Texture_VBOID );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, this->ml_Texture_VBOID );
// Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, ml_RenderListLength * 4 * sizeof(class clsVert), this->m_Texture_Verts_ptr, GL_STATIC_DRAW_ARB );
and the following is the draw routine
glBindBufferARB( GL_ARRAY_BUFFER_ARB, this->ml_VBOID );
glVertexPointer( 2, GL_FLOAT, 0, this->m_Pos_Verts_ptr ); // Set The Vertex Pointer To The Vertex Buffer
glBindBufferARB( GL_ARRAY_BUFFER_ARB, this->ml_Texture_VBOID );
glTexCoordPointer( 2, GL_FLOAT, 0, this->m_LastTexture_Verts_ptr ); // Set The TexCoord Pointer To The TexCoord Buffer
glDrawArrays( GL_QUADS, 0, this->ml_RenderListLength * 4 ); // Draw All Of The Triangles
//clean up
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );