SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
TextureManager.h
1#ifndef TextureManager_H
2#define TextureManager_H
3
4#include "AzulCore.h"
5#include <string>
6#include <map>
7
8class Texture;
9
17class TextureManager
18{
19private:
20 friend class TextureManagerAttorney;
21
22 static TextureManager* ptrInstance;
23
24 TextureManager();
25 TextureManager(const TextureManager&) = delete;
26 TextureManager& operator=(const TextureManager&) = delete;
27 ~TextureManager() = default;
28
29 static TextureManager& Instance()
30 {
31 if (ptrInstance == nullptr)
32 ptrInstance = new TextureManager();
33 return *ptrInstance;
34 };
35
39 const std::string defaultPath;
40
44 std::map<std::string, Texture*> storageMap;
45
49 static void Delete() { Instance().privDelete(); }
50 void privDelete();
51
52 Texture* privGet(const std::string& key);
53 void privLoad(const std::string& key, const std::string& path);
54 void privLoad(const std::string& key, const unsigned char& red, const unsigned char& green, const unsigned char& blue);
55
56public:
63 static Texture* Get(const std::string& key) { return Instance().privGet(key); }
64
71 static void Load(const std::string& key, const std::string& path) { Instance().privLoad(key, path); }
72
81 static void Load(const std::string& key, const unsigned char& red, const unsigned char& green, const unsigned char& blue) { Instance().privLoad(key, red, green, blue); }
82};
83
84#endif
std::map< std::string, Texture * > storageMap
Map storing Texture objects associated with their keys.
Definition TextureManager.h:44
static Texture * Get(const std::string &key)
Retrieves a Texture object by its key.
Definition TextureManager.h:63
static void Delete()
Deletes all managed Texture objects.
Definition TextureManager.h:49
const std::string defaultPath
Default path for loading textures.
Definition TextureManager.h:39
static void Load(const std::string &key, const std::string &path)
Loads a Texture object from a file path.
Definition TextureManager.h:71
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.
Definition TextureManager.h:81