VBO krasch


Im new at VBO and I have some problem with my program. I want to use the VBO extension and it works great for just vertices and texcoords.

But when I try to add the normals and tangents the program just krasch. Here is my code:

//Init function
void BuildVBOs(struct TDS_Mesh_t & mesh)

glGenBuffersARB(1, &(mesh.m_nVBOVertices));				
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mesh.m_nVBOVertices);			// Bind The Buffer
glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh.NumVertex*3*sizeof(float), mesh.Vertex, GL_STATIC_DRAW_ARB );

glGenBuffersARB( 1, &mesh.m_nVBOTexCoords );				
glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh.m_nVBOTexCoords );		// Bind The Buffer
glBufferDataARB( GL_ARRAY_BUFFER_ARB, mesh.NumVertex*2*sizeof(float), mesh.UV, GL_STATIC_DRAW_ARB );

glGenBuffersARB(1, &(mesh.m_nVBONormals));
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mesh.m_nVBONormals); // Bind The Buffer
glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh.NumVertex3sizeof(float), mesh.Normal, GL_STATIC_DRAW_ARB );

glGenBuffersARB(1, &(mesh.m_nVBOTangents));
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mesh.m_nVBOTangents);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh.NumVertex3sizeof(float), mesh.Tangent, GL_STATIC_DRAW_ARB );

//Draw function
void Draw(struct TDS_Mesh_t & mesh)


glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh.m_nVBOVertices );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );

glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh.m_nVBOTexCoords );
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );

glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh.m_nVBONormals );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );

glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh.m_nVBOTangents );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );

glDrawElements(GL_TRIANGLES, mesh.NumFace*3, GL_UNSIGNED_SHORT, mesh.Face);

glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );


I have my tangents sent through the color channel and it works nice without VBO, so thats not the problem right? Anyone see whats wrong?

//Regards, Ninja

You have call 3 times glVertexPointer in Draw().
It look like copy/paste coding…


Ok, thanks!