aboutsummaryrefslogtreecommitdiffstats
path: root/src/texture_cache.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-04-02 09:15:30 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-04-02 09:15:30 +0100
commit21a147c3c1c2fad2819fe76becab320c51eb131f (patch)
tree9114123be1d9165a199d8b27af8f9b4e00333e71 /src/texture_cache.cpp
downloadYAGE-21a147c3c1c2fad2819fe76becab320c51eb131f.tar.gz
YAGE-21a147c3c1c2fad2819fe76becab320c51eb131f.zip
Adding initial files
Diffstat (limited to 'src/texture_cache.cpp')
-rw-r--r--src/texture_cache.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/texture_cache.cpp b/src/texture_cache.cpp
new file mode 100644
index 00000000..c57538b6
--- /dev/null
+++ b/src/texture_cache.cpp
@@ -0,0 +1,22 @@
+#include "image_loader.hpp"
+#include "texture_cache.hpp"
+
+TextureCache::TextureCache()
+{}
+
+TextureCache::~TextureCache()
+{}
+
+GlTexture TextureCache::getTexture(const std::string &texture_path)
+{
+ auto itr = texture_map_.find(texture_path);
+
+ if(itr == texture_map_.end())
+ {
+ GlTexture new_texture = ImageLoader::loadPng(texture_path);
+ texture_map_.insert(make_pair(texture_path, new_texture));
+ return new_texture;
+ }
+
+ return itr->second;
+}