VEGO-Engine  0.1
Loading...
Searching...
No Matches
TextureManager Class Reference

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.
 

Detailed Description

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.

See also
Textures are used to identify textures within the engine. It is expected that they are implemented within the games scope.

Member Function Documentation

◆ addSingleTexture()

void TextureManager::addSingleTexture ( Textures texture,
const char * filePath )

Adds a single texture to the cache.

Parameters
textureThe texture identifier.
filePathThe file path to the texture file.
Exceptions
std::runtime_errorIs thrown if the texture could not be loaded correctly

This function loads the texture from the specified file and stores it in a cache.

◆ addTextures()

void TextureManager::addTextures ( const std::map< Textures, const char * > & textures)

Adds multiple textures to the cache.

Parameters
texturesA 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.

◆ loadMapTileTexture()

SDL_Texture * TextureManager::loadMapTileTexture ( const char * path)

Loads a map tile texture from the file system and caches it.

Parameters
pathThe file path to the texture.
Returns
SDL_Texture* representing the map tile.
Exceptions
std::runtime_errorIs 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.

Todo
should not be usable for the developer and only be accessed by the map class

◆ loadTexture()

SDL_Texture * TextureManager::loadTexture ( Textures texture)

Loads a texture from the cache.

Parameters
textureThe texture identifier.
Returns
A pointer to the 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.


The documentation for this class was generated from the following files: