So using TextureAtlas.addRegion(TextureRegion) won’t reduce the number of texture binds?
Imagine TextureAtlas is a HashMap of <String, TextureRegion> pairs. Say you load a packed atlas with one 256x256 texture, which contains three named sprites. When rendering, you still only have a single texture.
Since it’s a hash map, you can put another TextureRegion into the map by a String key. If that TextureRegion uses the same Texture object, then it won’t result in any other texture binds. If, on the other hand, your TextureRegion uses a different Texture object, then it will lead to more texture binds.
Hopefully these articles will help clear the air regarding sprite batching and texture regions:
I understand batching and binds. I just was not sure if TextureAtlas created merged textures. Thanks. TextureAtlas has no use for me then. Is there a way to merge textures, through code?
Yeah search for libgdx texture packer
Its just some lines of code
I don’t mean the LibGDX texturepacker. I mean as I load my textures I would like to merge them with textures that I have labeled part of a group. Because as I progress in my game I don’t want to have to redo all the textures. I just label them part of a group in my game files and when the game laods it I want it merged with another texture loaded of the group. I have been using TextureAtlas.addRegion for this, but it does not reduce texture binds, as I now know.
Nvm, I just decided to create a quick program that just recompiles my dat files and merges the pngs based on their group labels.
actually the idea was to do what you want by integating the libgdx texture packer in your game…
There is also PixmapPacker which can pack sprites during runtime.
Here’s a texture packer based on blackpawn’s heuristic:
www.rel.phatcode.net/junk.php?id=106
If you want to implement your own packer.
Davedes that is exactly what I was looking for!