I would like to fill a VBO with element indices, and then later bind it to the GL_ELEMENT_ARRAY_BUFFER slot on a VAO.
The obvious (but wrong) code is:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ...);
but that changes the current VAO, or could cause an error if there is no VAO bound. I don't want to do that, I just want to fill the buffer, and then use it at some later point
If this would be OpenGL 4.5 (which osx doesn't support), the solution would be to just use glNamedBufferData, and not bind it until later.
Is there a reasonable way around this?
Can i use the GL_ARRAY_BUFFER slot to fill the buffer, and then bind it to GL_ELEMENT_ARRAY_BUFFER later, or would that be against the spec?