So I am making a 3D batchrenderer for my engine, and the basic concept is that we make large enough VBO and IBO to accompany all the vertex data(positions, normals, uv etc.) and update the VBO using glMapBuffer or using glbuffersubdata everyframe if we want to make any changes, but in this case the pattern of the IBO (Index Buffer) is predefined (i.e. we assume we have quads and fill it with 012230 for the entirety of the IBO size) but when using 3D models this won't be the case the IBOs data would be different, so how do I change the IBO data if I instantiate a new model or suppose if I am generating a UV sphere and want to change it's subdivisions?

I have no idea how to deal with dynamically changing(need not be frequent) indices data when using VAOs, VBOs and Index Buffers.

As per OpenGL 4.5, core profile, reading from client memory is unsupported (§10.3.10 OpenGL 4.5 core spec):

DrawElements, DrawRangeElements, and DrawElementsInstanced source their indices from the buffer object whose name is bound to ELEMENT_ARRAY_BUFFER, using their indices parameters as offsets into the buffer object in the same fashion as described in section 10.3.9. [...] If zero is bound to ELEMENT_ARRAY_BUFFER, the result of these drawing commands is undefined.

so we cannot map the ELEMENT_ARRAY_BUFFER using glMapBuffer or glBufferSubData (or can we?), and glDrawElements does accept a pointer to indices data but only when we are not using VAOs and VBOs, if we are using them it takes the last argument as a pointer offset in the currently bound ELEMENT_ARRAY_BUFFER.

So what's the best way to deal with dynamic indices?

  • \$\begingroup\$ Well I did stumble across someone using glEnableClientState to update the the buffers but I guess it was deprecated in modern OpenGL. \$\endgroup\$
    – Pikachuxxx
    Dec 28, 2020 at 13:47
  • \$\begingroup\$ You can make new VAO with new index buffer and delete the old one. \$\endgroup\$
    – Hihikomori
    Dec 28, 2020 at 15:01
  • \$\begingroup\$ Like is there a way to update the IBO in the same way we update a VBO using glBufferSubData so that I could only update the indices for a single mesh in a batched meshes buffer? I also want to make it as performance optimal as possible. \$\endgroup\$
    – Pikachuxxx
    Dec 28, 2020 at 16:29
  • \$\begingroup\$ Actually glBufferSubData should work for ELEMENT_ARRAY_BUFFER. IBO is VBO with ELEMENT_ARRAY_BUFFER target. How mannipulations with it differ from ARRAY_BUFFER? \$\endgroup\$
    – Hihikomori
    Dec 28, 2020 at 16:44
  • \$\begingroup\$ when I checked the docs glMapBuffer doesn't support ELEMENT_ARRAY_BUFFER, so I haven't checked it with glBufferSubData, I will try it and see. Seems like the documentation for glBufferSubData supports ELEMENT_ARRAY_BUFFER, I wonder why glMapBuffer doesn't support it, anyways thanks. \$\endgroup\$
    – Pikachuxxx
    Dec 28, 2020 at 16:48

1 Answer 1


This is the idea how to upload data to gpu:

memcpy(vbo, indices, byteSize);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .