I've been reading Beginning Android Games and it says there that SpriteBatcher.begin() binds the texture to be used and and clears the buffers. My question concerns the correct usage of Texture Atlases to limit the amount of time it takes to bind those textures . In the case that one ABSOLUTELY needs to use different SpriteBatchers for different sprites should one use the smallest possible number of texture atlases for the whole series of batch.begin, batch.end series?
Or is it faster to use more TextureAtlases that will be smaller in size, one for each batch.begin, batch.end session? Because smaller texture atlases means less time to bind them.
In general there shouldn't be a real reason to have more than a single
SpriteBatch. And you should also keep your
end() calls to a minimum.
The more batches you use, and the more often you interrupt the batching via begin/end, the more performance you will lose.
If you have only single textures for your sprites and you fire your draw calls in this order A, B, A, B, A, B, then you'll have up to 6 texture bindings.
If you put both of those textures into a
TextureAtlas, they will have the same texture, and there will be just a single texture binding.
The size of your atlas pages usually shouldn't make a difference. All that happens in the background is another ID to be set, the actual texture won't be moved anywhere, or processed anyhow, when you just bind another texture.
Thus you should use texture atlas pages that are as big as possible. However there is a tradeoff. The bigger the page size, the more likely some devices won't support those sizes anymore. Plus, the bigger your page size, the more memory you are likely to waste, because the pages aren't filled completely, or because you will only use a very small part of the page, but it still needs to be loaded completely.