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 toELEMENT_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?