I'm currently building a game engine renderer but I got stuck when I had to separate engine and client code.
I had been following OpenGL tutorials to learn about buffer creation, etc so all my code for rendering was in a single place and was tied to that specific example.
I created a VBO, a IBO/EBO, a VAO and a shader, then set the
VertexAttribPointers for that VAO (and VBO layout) and rendered it. Everything worked fine.
Then I created C++ abstractions for all of those "objects" and recreated the example; that also worked.
So what I wanted to do know is to have each of my game objects create a VBO and an IBO, create a global VAO in my renderer (since all my objects share the same layout) submit them to the renderer and have them rendered. But I discovered I could not setup vertex attribute pointers without having a VBO bound (I have none bound since they get created after the renderer starts up).
So my question is:
How should I set up the VAOs and VBOs for the renderer to work?
I read in some places that what I have to do is to set up few VBOs (so as to have little binding calls and draw calls) and then store every object inside that one giant buffer. (Of course while still creating different buffers for objects with different vertex layouts and different shaders). I also know that to do that you have to allocate a big buffer and then call buffer sub data to store the new data inside that one buffer, but what I don't know is how to store that data if it must be offset (because of its position in the world and how to update its position)
So if that's the case my next question is:
How do I create one giant buffer and then store different objects inside that one giant buffer and then render those stored objects with their respective positions? (For both static and dynamic objects).