Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am working on simple 2D engine using OpenGL (3.3+) for rendering and was wondering what the optimal method of sprite batching would be. I plan to put all sprites into one (or fewer) texture atlases. Unsurprisingly, each sprite consists of 2 triangles and 4 texture coordinates. For simplicity, let's assume only the sprites are not animated for now.

Now to my question, I do not know what would be the optimal way to draw them. As far as I was able to dig up, I have two options:

  1. Draw each sprite separately, which would allow me to modify the position/rotation/scale of each sprite within the shader via MVP matrices. This also means that I would not need to update the sprite data buffers (vertex pos. & tex. coords) on GPU.

  2. Stuff all sprites' data into a single VBO and draw them all with one glDrawElements call (assuming they use the same texture atlas and shader). However, I would then need to update the VBO every frame (or at least the changed parts, which also means that I would have to watch every sprite's state).

Which of these options is better from a practical point of view? Or is there any other method to achieve what I'm trying to do?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.