The Table Engine
|
Singleton class for managing game resources like textures and fonts. More...
#include <resourcemanager.h>
Public Member Functions | |
void | setRenderer (SDL_Renderer *renderer) |
Sets the renderer for resource management. More... | |
SDL_Renderer * | getRenderer () |
Gets the current renderer. More... | |
SDL_Texture * | loadTexture (std::string path) |
Loads a texture from a specified file path. More... | |
SDL_Texture * | loadText (std::string font_path, std::string text, SDL_Color color, int font_size=20) |
Loads a text as a texture using a specified TTF font. More... | |
Static Public Member Functions | |
static ResourceManager & | getInstance () |
Retrieves the singleton instance of ResourceManager. More... | |
Private Member Functions | |
ResourceManager () | |
Private constructor for singleton pattern. More... | |
ResourceManager (const ResourceManager &)=delete | |
Deleted copy constructor to prevent multiple instances. More... | |
void | operator= (const ResourceManager &)=delete |
Deleted assignment operator to prevent multiple instances. More... | |
Private Attributes | |
SDL_Renderer * | m_renderer |
Renderer used to render game objects. More... | |
std::unordered_map< std::string, SDL_Texture * > | m_imageResourceMap |
Cache of texture resources. More... | |
std::unordered_map< std::string, TTF_Font * > | m_fontMap |
Cache of font resources. More... | |
Singleton class for managing game resources like textures and fonts.
This class is responsible for loading, caching, and providing access to various game resources, including textures and fonts, to reduce I/O overhead during gameplay.
Definition at line 26 of file resourcemanager.h.
|
private |
Private constructor for singleton pattern.
Definition at line 36 of file resourcemanager.h.
|
privatedelete |
Deleted copy constructor to prevent multiple instances.
|
static |
Retrieves the singleton instance of ResourceManager.
Definition at line 53 of file resourcemanager.h.
SDL_Renderer * ResourceManager::getRenderer | ( | ) |
Gets the current renderer.
Definition at line 9 of file resourcemanager.cpp.
SDL_Texture * ResourceManager::loadText | ( | std::string | font_path, |
std::string | text, | ||
SDL_Color | color, | ||
int | font_size = 20 |
||
) |
Loads a text as a texture using a specified TTF font.
font_path | Path to the font file. |
text | Text string to render. |
color | SDL_Color for the text. |
font_size | Size of the font to be used (default is 20). |
Definition at line 42 of file resourcemanager.cpp.
SDL_Texture * ResourceManager::loadTexture | ( | std::string | path | ) |
Loads a texture from a specified file path.
path | Path to the image file. |
Definition at line 20 of file resourcemanager.cpp.
|
privatedelete |
Deleted assignment operator to prevent multiple instances.
void ResourceManager::setRenderer | ( | SDL_Renderer * | renderer | ) |
Sets the renderer for resource management.
renderer | Pointer to the SDL_Renderer to be used for rendering. |
Definition at line 14 of file resourcemanager.cpp.
|
private |
Cache of font resources.
Definition at line 31 of file resourcemanager.h.
|
private |
Cache of texture resources.
Definition at line 30 of file resourcemanager.h.
|
private |
Renderer used to render game objects.
Definition at line 29 of file resourcemanager.h.