SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
TextureManager Class Reference

Manages the loading, retrieval, and deletion of Texture objects. More...

#include <TextureManager.h>

Static Public Member Functions

static Texture * Get (const std::string &key)
 Retrieves a Texture object by its key.
 
static void Load (const std::string &key, const std::string &path)
 Loads a Texture object from a file path.
 
static void Load (const std::string &key, const unsigned char &red, const unsigned char &green, const unsigned char &blue)
 Loads a single pixel Texture object with specified color.
 

Private Member Functions

 TextureManager (const TextureManager &)=delete
 
TextureManageroperator= (const TextureManager &)=delete
 
void privDelete ()
 
Texture * privGet (const std::string &key)
 
void privLoad (const std::string &key, const std::string &path)
 
void privLoad (const std::string &key, const unsigned char &red, const unsigned char &green, const unsigned char &blue)
 

Static Private Member Functions

static TextureManagerInstance ()
 
static void Delete ()
 Deletes all managed Texture objects.
 

Private Attributes

const std::string defaultPath
 Default path for loading textures.
 
std::map< std::string, Texture * > storageMap
 Map storing Texture objects associated with their keys.
 

Static Private Attributes

static TextureManagerptrInstance = nullptr
 

Friends

class TextureManagerAttorney
 

Detailed Description

Manages the loading, retrieval, and deletion of Texture objects.

The TextureManager class is responsible for managing Texture objects, including loading textures from files, creating single pixel textures, retrieving textures by key, and deleting all managed textures. It follows the Singleton design pattern.

Member Function Documentation

◆ Get()

static Texture * TextureManager::Get ( const std::string & key)
inlinestatic

Retrieves a Texture object by its key.

Parameters
keyThe key associated with the Texture object.
Returns
A pointer to the Texture object, or nullptr if the key is not found.
Here is the caller graph for this function:

◆ Load() [1/2]

static void TextureManager::Load ( const std::string & key,
const std::string & path )
inlinestatic

Loads a Texture object from a file path.

Parameters
keyThe key to associate with the Texture object.
pathThe file path to load the texture from.
Here is the caller graph for this function:

◆ Load() [2/2]

static void TextureManager::Load ( const std::string & key,
const unsigned char & red,
const unsigned char & green,
const unsigned char & blue )
inlinestatic

Loads a single pixel Texture object with specified color.

Parameters
keyThe key to associate with the Texture object.
redThe red component of the color.
greenThe green component of the color.
blueThe blue component of the color.

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