Just for learning purpose I want to build a really simple 2D openGL Engine, so I'm really curious to understand how the most famous Engines work (or at least which is your idea).
I know that using a SpriteBatches the engine performs a single drawing call per SpriteBatch while drawing simple sprites every sprite needs a drawing call. Let's say that I'm only interested in drawing separated sprites without a SpriteBatch.
Here is my idea for simple Sprites drawing:
I suppose they are represented through a plane and a texture. Every plane has a set of vertices and indices and a common shader (let's keep it simple).
The sprites are stored in a sort of array and for each sprites the engine needs to set a VBO
with the vertices of the current plane and call glBindBuffer
, glBufferData
, set the shaders and call glDrawElements
.
The VBO is then cleared and the previous operations are repeated for the next sprite.
Could it be a common routine to draw sprites?
About the SpriteBatch I suppose that the big difference is that the VBO stores the vertices of every plane once and for this reason it is able to draw all the sprites in a single glDrawElements
call.
Am I on the right way or my "suppositions" are totally wrong?