A texture atlas describes the concept of a single texture that contains multiple objects. You may also encounter other terms, such as sprite sheet, or tile set in the case of squared tiles put together. Texture atlases allow having fewer image files, which decreases the amount of switches between different textures at runtime. Since texture switching is a rather slow operation on the graphics card, using texture atlases may result in notable speedups. Till now, we used separate textures for each object: one for each aircraft, pick-up, projectile, button, and background. Every texture was stored in its own PNG file. The code design looked as follows:
Textures were stored inside
TextureHolder, our container storing
We had an enum
Textures::IDto identify the different textures in a
TextureHolder. By that, we could easily refer to different textures without knowing the actual
sf::Textureobject or the filename.
The textures used in the scene were...