I have my VBO code working right now but I'm wondering if there is a better way to go about it. I've read that loading all the information for a given model into one buffer is a good way. I've read that loading all models into one buffer and managing them through memory manipulation is a good way to go.
loading code:
glGenBuffersARB( 1, &VertexID ); // Get A Valid Name
glBindBufferARB( GL_ARRAY_BUFFER_ARB, VertexID ); // Bind The Buffer
glBufferDataARB( GL_ARRAY_BUFFER_ARB, VertexCount*3*sizeof(float), VertexData, GL_STATIC_DRAW_ARB ); // Load The Data
// Generate And Bind The Texture Coordinate Buffer
glGenBuffersARB( 1, &NormalID ); // Get A Valid Name
glBindBufferARB( GL_ARRAY_BUFFER_ARB, NormalID ); // Bind The Buffer
glBufferDataARB( GL_ARRAY_BUFFER_ARB, NormalCount*2*sizeof(float), NormalData, GL_STATIC_DRAW_ARB ); // Load The Data
// Generate And Bind The Texture Coordinate Buffer
glGenBuffersARB( 1, &TexcoordID ); // Get A Valid Name
glBindBufferARB( GL_ARRAY_BUFFER_ARB, TexcoordID ); // Bind The Buffer
glBufferDataARB( GL_ARRAY_BUFFER_ARB, TexCoordCount*2*sizeof(float), TexCoordData, GL_STATIC_DRAW_ARB ); // Load The Data
Rendering code:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0.0f, 0.0f, -5.0f);
if (MyModel->Vertexs == true)
{
glBindBufferARB( GL_ARRAY_BUFFER_ARB, MyModel->VertexID);
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL ); // Set The Vertex Pointer To The Vertex Buffer
}
if (MyModel->Normals == true)
{
glBindBufferARB( GL_ARRAY_BUFFER_ARB, MyModel->NormalID );
glNormalPointer( GL_FLOAT, 0, (char *) NULL ); // Set The Normal Pointer To The Normal Buffer
}
if (MyModel->TexCoords == true)
{
glBindBufferARB( GL_ARRAY_BUFFER_ARB, MyModel->TexcoordID );
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // Set The TexCoord Pointer To The TexCoord Buffer
}
glDrawArrays( GL_TRIANGLES, 0, MyModel->VertexCount ); // Draw All Of The Triangles At Once
then rendering it like so:
int DrawGLScene(Model *MyModel)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0.0f, 0.0f, -5.0f);
I may be wrong but from the code it looks to me like the glBufferSubData() calls are all writing in the same location (each call is overriding the data uploaded by the previous call).