/
TextureManager.h
59 lines (48 loc) · 1.22 KB
/
TextureManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _TEXTURE_MANAGER_H_
#define _TEXTURE_MANAGER_H_
#include <string>
#include <memory>
#include <map>
#include <memory>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
namespace typing
{
class Texture
{
public:
// Ctors/Dtors
Texture() : m_id(0)
{
}
// Methods
void Load(const std::string& textureName);
void Bind() const;
private:
GLuint m_id;
};
typedef std::shared_ptr<Texture> TexturePtr;
class TextureManager
{
public:
// Singleton Implementation
static TextureManager& GetTextureManager();
// Methods
void Add(const std::string& textureName);
const Texture& Get(const std::string& textureName) const;
void Bind(const std::string& textureName) const;
private:
// Ctors/Dtors
TextureManager()
{
}
// Typedefs
typedef std::map<std::string, TexturePtr> TextureMap;
// Members
TextureMap m_textureMap;
// Singleton Implementation
static std::auto_ptr<TextureManager> m_singleton;
};
#define TEXTURES TextureManager::GetTextureManager()
}
#endif // _TEXTURE_MANAGER_H_