My Project
|
Manages the loading, access, and unloading of resources such as textures. More...
#include <ResourceManager.h>
Public Member Functions | |
void | LoadResource (SDL_Renderer *renderer, const std::string &image_filename) |
Loads a texture resource. | |
SDL_Texture * | GetResource (const std::string &key) |
Retrieves a loaded texture resource. | |
int | StartUp () |
Initializes the ResourceManager. | |
int | ShutDown () |
Performs cleanup tasks for the ResourceManager. | |
Static Public Member Functions | |
static ResourceManager & | GetInstance () |
Retrieves the singleton instance of ResourceManager. | |
Manages the loading, access, and unloading of resources such as textures.
The ResourceManager class follows the Singleton design pattern to ensure only one instance manages all resources in the application. It provides methods to load resources from files, retrieve loaded resources, and perform cleanup on shutdown.
|
static |
Retrieves the singleton instance of ResourceManager.
Provides global access to the singleton instance of the resource manager.
SDL_Texture * ResourceManager::GetResource | ( | const std::string & | key | ) |
Retrieves a loaded texture resource.
key | The identifier of the resource to retrieve. |
Looks up a resource by its identifier and returns a pointer to the SDL_Texture if it exists.
void ResourceManager::LoadResource | ( | SDL_Renderer * | renderer, |
const std::string & | image_filename ) |
Loads a texture resource.
renderer | Pointer to the SDL_Renderer to use for texture creation. |
image_filename | The path to the image file to load. |
Loads an image from the specified file path and creates an SDL_Texture from it. The texture is stored in the resources container.
int ResourceManager::ShutDown | ( | ) |
Performs cleanup tasks for the ResourceManager.
Frees all loaded resources and prepares the resource manager for shutdown.
int ResourceManager::StartUp | ( | ) |
Initializes the ResourceManager.
Initializes the ResourceManager.