|
VEGO-Engine
0.1
|
A manager for loading, caching, and drawing textures. More...
#include <TextureManager.h>
Public Member Functions | |
| void | addSingleTexture (Textures texture, const char *filePath) |
| Adds a single texture to the cache. | |
| void | addTextures (const std::map< Textures, const char * > &textures) |
| Adds multiple textures to the cache. | |
| SDL_Texture * | loadTexture (Textures texture) |
| Loads a texture from the cache. | |
| SDL_Texture * | loadMapTileTexture (const char *path) |
| Loads a map tile texture from the file system and caches it. | |
A manager for loading, caching, and drawing textures.
The TextureManager class is responsible for handling texture loading, caching, and rendering in the engine. It provides functions to add, load, and draw textures from files, as well as manage sprite sheets.
| void TextureManager::addSingleTexture | ( | Textures | texture, |
| const char * | filePath ) |
Adds a single texture to the cache.
| texture | The texture identifier. |
| filePath | The file path to the texture file. |
| std::runtime_error | Is thrown if the texture could not be loaded correctly |
This function loads the texture from the specified file and stores it in a cache.
| void TextureManager::addTextures | ( | const std::map< Textures, const char * > & | textures | ) |
Adds multiple textures to the cache.
| textures | A map of texture identifiers and corresponding file paths. |
This function iterates over the provided map of textures and loads each texture using addSingleTexture. It allows for several textures to be added at once.
| SDL_Texture * TextureManager::loadMapTileTexture | ( | const char * | path | ) |
Loads a map tile texture from the file system and caches it.
| path | The file path to the texture. |
SDL_Texture* representing the map tile. | std::runtime_error | Is thrown if the texture could not be loaded correctly |
This function checks if the map tile texture is already cached. If not, it loads the texture from the file system and stores it in the cache.
| SDL_Texture * TextureManager::loadTexture | ( | Textures | texture | ) |
Loads a texture from the cache.
| texture | The texture identifier. |
SDL_Texture if found, or nullptr if not found.This function looks up a texture within the cache and returns the corresponding SDL_Texture*. If the texture is not found, it logs an error message and returns nullptr.