-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextureManager.cpp
More file actions
52 lines (33 loc) · 919 Bytes
/
Copy pathTextureManager.cpp
File metadata and controls
52 lines (33 loc) · 919 Bytes
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
#include "TextureManager.h"
Texture TextureManager::GetTexture(const char* filepath)
{
auto pos = textures.find(filepath);
if (pos == textures.end()) {
Texture texture = Texture(filepath, GL_TEXTURE_2D, GL_TEXTURE0, GL_RGBA, GL_UNSIGNED_BYTE);
textures.insert(std::pair<string, Texture>(filepath, texture));
return texture;
}
else {
return pos->second;
}
}
Texture TextureManager::GetCubemapTexture(const char* filepath)
{
auto pos = textures.find(filepath);
if (pos == textures.end()) {
Texture texture = Texture(filepath, GL_TEXTURE_CUBE_MAP, GL_TEXTURE0, GL_RGBA, GL_UNSIGNED_BYTE);
textures.insert(std::pair<string, Texture>(filepath, texture));
return texture;
}
else {
return pos->second;
}
}
void TextureManager::Delete() {
map<string, Texture>::iterator it;
for (it = textures.begin(); it != textures.end(); it++)
{
it->second.Delete();
}
delete this;
}