27 TextureManager(
Manager* manager) : manager(manager) {}
29 for (
auto& it : this->texture_cache) {
30 SDL_DestroyTexture(it.second);
32 for (
auto& it : this->mapTile_texture_cache) {
33 SDL_DestroyTexture(it.second);
56 void addTextures(
const std::map<Textures, const char*>& textures);
68 static std::vector<SDL_Rect> splitSpriteSheet(SDL_Texture* spriteSheet,
int width,
int height,
int spritesOnSheet);
69 static void draw(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FRect src, SDL_FRect dest,
bool flipped =
false);
71 void setScaleMode(SDL_ScaleMode scaleMode) { this->scaleMode = scaleMode; }
86 std::string getTexturePath(
Textures texture) {
87 return this->texture_references.at(texture);
91 SDL_ScaleMode scaleMode = SDL_SCALEMODE_NEAREST;
93 std::map<Textures, SDL_Texture*> texture_cache;
94 std::map<std::string, SDL_Texture*> mapTile_texture_cache;
96 std::map<Textures, std::string> texture_references;
SDL_Texture * loadTexture(Textures texture)
Loads a texture from the cache.
Definition TextureManager.cpp:31
void addTextures(const std::map< Textures, const char * > &textures)
Adds multiple textures to the cache.
Definition TextureManager.cpp:24
void addSingleTexture(Textures texture, const char *filePath)
Adds a single texture to the cache.
Definition TextureManager.cpp:10
SDL_Texture * loadMapTileTexture(const char *path)
Loads a map tile texture from the file system and caches it.
Definition TextureManager.cpp:47
Forward declaration of the Textures enum class.