My Project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
ResourceManager Class Reference

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 ResourceManagerGetInstance ()
 Retrieves the singleton instance of ResourceManager.
 

Detailed Description

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.

Member Function Documentation

◆ GetInstance()

ResourceManager & ResourceManager::GetInstance ( )
static

Retrieves the singleton instance of ResourceManager.

Returns
Reference to the singleton ResourceManager instance.

Provides global access to the singleton instance of the resource manager.

◆ GetResource()

SDL_Texture * ResourceManager::GetResource ( const std::string & key)

Retrieves a loaded texture resource.

Parameters
keyThe identifier of the resource to retrieve.
Returns
Pointer to the SDL_Texture associated with the key, or nullptr if not found.

Looks up a resource by its identifier and returns a pointer to the SDL_Texture if it exists.

◆ LoadResource()

void ResourceManager::LoadResource ( SDL_Renderer * renderer,
const std::string & image_filename )

Loads a texture resource.

Parameters
rendererPointer to the SDL_Renderer to use for texture creation.
image_filenameThe 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.

◆ ShutDown()

int ResourceManager::ShutDown ( )

Performs cleanup tasks for the ResourceManager.

Frees all loaded resources and prepares the resource manager for shutdown.

◆ StartUp()

int ResourceManager::StartUp ( )

Initializes the ResourceManager.

Initializes the ResourceManager.


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