forked from Barnold1953/GraphicsTutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextureCache.cpp
More file actions
33 lines (24 loc) · 722 Bytes
/
TextureCache.cpp
File metadata and controls
33 lines (24 loc) · 722 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
#include "TextureCache.h"
#include "ImageLoader.h"
#include <iostream>
namespace Bengine {
TextureCache::TextureCache()
{
}
TextureCache::~TextureCache()
{
}
GLTexture TextureCache::getTexture(std::string texturePath) {
//lookup the texture and see if its in the map
auto mit = _textureMap.find(texturePath);
//check if its not in the map
if (mit == _textureMap.end()) {
//Load the texture
GLTexture newTexture = ImageLoader::loadPNG(texturePath);
//Insert it into the map
_textureMap.insert(make_pair(texturePath, newTexture));
return newTexture;
}
return mit->second;
}
}