Transformations on VBOs

I’m currently trying to perform transformations on vertex data stored in a VBO. I’m storing vertex data representing multiple meshes in a single VBO, and then attempting to apply separate transformations (glRotatef, glTranslate, etc) between glDrawArray calls. This is not working as expected, in fact, both meshes are simply rendering on top of each other and all the transformations are applying to all the glDrawArray calls. Any guidance on the solution to this would be awesome.

// Bind the buffer object, this is storing mesh 1 and mesh 2 vertex data
glBindBuffer(GL_ARRAY_BUFFER, mFBO);

// Transform mesh 1
glRotatef(0.5f, 1.0f, 1.0f, 0.0f);

glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
glVertexPointer(4, GL_FLOAT, 0, mesh1VertexOffset);

// Commit mesh 1 data (0 -> mesh 1 index length)
glDrawArrays(GL_TRIANGLES, 0, mesh1IndicesLen);

// Transform mesh 2
glTranslatef(0.002f, 0.0f, 0.0f);

glColorPointer(4, GL_UNSIGNED_BYTE, 0, mesh2ColorOffset);
glVertexPointer(4, GL_FLOAT, 0, mesh1VertexOffset + mesh2ColorOffset);

// Commit mesh 2 data (mesh 1 index length -> mesh 2 index length)
glDrawArrays(GL_TRIANGLES, mesh1IndicesLen, mesh2IndicesLen);

Solved the issue. This can be achieved using glPushMatrix() and glPopMatrix(), which I was doing but improperly within the context of VBOs :roll:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.