aboutsummaryrefslogtreecommitdiffstats
path: root/src/texture_cache.cpp
diff options
context:
space:
mode:
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;
+}