Hello, I am attempting to create my own Sprite Batcher for my game. Though I am having trouble understanding how they work. I understand their implementation, but not how they actually work. How do they manage vertex data and actually render the sprites? I have tried looking at Matt’s examples but I cannot figure anything out. Could someone shed some light on the matter?
What could you not figure out?
Before you attempt to create a sprite batcher, it’s important to understand concepts like textures, vertices, and so forth. You also need to understand shaders; how vertex attributes are passed to the vertex shader, and in turn passed to the frag shader. And you need to have at least a basic understanding of how to set up matrices for your orthographic projection.
If you don’t understand these things, then you have a lot of reading ahead of you:
The last tutorial explains how to create your own sprite batcher from the ground up, using LibGDX’s utilities. Thus, it doesn’t explain the “low level” OpenGL calls that Mesh and ShaderProgram use under the hood. If you are keen to learn how to utilize these functions, you will need to read some OpenGL-specific tutorials:
Lots more OpenGL tutorials here:
http://www.gamefromscratch.com/post/2013/02/27/Modern-OpenGL-resources-round-up.aspx
If you still can’t figure it out – then I would suggest starting with LibGDX instead of going straight to OpenGL functions. It will help ease you into graphics programming, and should make the transition a little nicer.
I understand how Vertex Arrays, Vertex Buffers, Shaders and Textures work. I just didn’t understand how a Sprite Batcher would incorporate all of these aspects. Though browsing through the first tutorial on meshes, that seems to be what I am looking for. I’ll have a read through it and see if it can help me out.