I’m trying to draw two different meshes that belong to the same VBO using glDrawElementsBaseVertex. I’m drawing the first mesh (name “object”) successfully, but the second mesh (named “plane”) is no where to be found.
glDrawElementsBaseVertex ( GL_TRIANGLES, objectIndexSize, GL_UNSIGNED_INT, ( void * ) ( objectVertexBytes ), 0 );
glDrawElementsBaseVertex ( GL_TRIANGLES, objectIndexSize, GL_UNSIGNED_INT, ( void * ) ( planeVertexBytes ), 0 );
I realize the last parameter (aka basevertex) for the subsequent (read: anything other than the first mesh in the VBO) should not be zero, but left it 0 here. As I understand it, basevertex should an offset so that the draw call starts at indices[i] + basevertex. To comform to this, I’ve tried a basevertex = objectIndexSize for the plane and had no success.
I’m wondering if this has to do with how I setup my buffer sources:
// Setup the buffer sources glVertexArrayElementBuffer ( vertexArray, buffer ); glVertexArrayVertexBuffer ( vertexArray, positionLocation, buffer, 0, 3 * sizeof ( float ) ); glVertexArrayVertexBuffer ( vertexArray, normalLocation, buffer, (objectVertexBytes + objectIndexBytes), 3 * sizeof ( float ) );
In fact, I’m almost certain it’s a problem, if not THE problem, but I’m not sure how to glVertexArrayVertexBuffer the same VBO with two different meshes with two different lengths of vertices and indices.
glVertexArrayVertexBuffer is on line 83.
glDrawElementsBaseVertex is on line 168.