summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-01-25 01:05:45 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-01-25 01:05:45 +0000
commita1110d7f594177976f9bd7cda73d11bc2e942a4a (patch)
tree9eaf1517f097c8a2086920022a2153d5ed137f4f
parentSplit physical objects from renderable ones (diff)
downloadilt-a1110d7f594177976f9bd7cda73d11bc2e942a4a.tar.bz2
ilt-a1110d7f594177976f9bd7cda73d11bc2e942a4a.tar.xz
ilt-a1110d7f594177976f9bd7cda73d11bc2e942a4a.zip
Move texture cache to Texture class
-rw-r--r--game/physical.cpp3
-rw-r--r--game/physical.h1
-rw-r--r--gfx/models/texture.cpp3
-rw-r--r--gfx/models/texture.h4
4 files changed, 8 insertions, 3 deletions
diff --git a/game/physical.cpp b/game/physical.cpp
index 17d85dd..ec3221f 100644
--- a/game/physical.cpp
+++ b/game/physical.cpp
@@ -6,10 +6,9 @@
#include <gfx/gl/transform.h>
Cache<Mesh> Physical::cachedMesh;
-Cache<Texture> Physical::cachedTexture;
Physical::Physical(glm::vec3 where, const std::string & m, const std::string & t) :
- location {where}, mesh {cachedMesh.get(m)}, texture {cachedTexture.get(t)}
+ location {where}, mesh {cachedMesh.get(m)}, texture {Texture::cachedTexture.get(t)}
{
}
diff --git a/game/physical.h b/game/physical.h
index 44af5e6..4ad8a49 100644
--- a/game/physical.h
+++ b/game/physical.h
@@ -32,7 +32,6 @@ protected:
private:
static Cache<Mesh> cachedMesh;
- static Cache<Texture> cachedTexture;
};
#endif
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index a388b32..90ec016 100644
--- a/gfx/models/texture.cpp
+++ b/gfx/models/texture.cpp
@@ -1,7 +1,10 @@
#include "texture.h"
#include "stb_image.h"
+#include <cache.h>
#include <stdexcept>
+Cache<Texture> Texture::cachedTexture;
+
Texture::Texture(const std::string & fileName) : m_texture {}
{
int width, height, numComponents;
diff --git a/gfx/models/texture.h b/gfx/models/texture.h
index 6ebf88d..30ba953 100644
--- a/gfx/models/texture.h
+++ b/gfx/models/texture.h
@@ -5,6 +5,8 @@
#include <special_members.hpp>
#include <string>
+template<typename Obj> class Cache;
+
class Texture {
public:
explicit Texture(const std::string & fileName);
@@ -14,6 +16,8 @@ public:
NO_COPY(Texture);
NO_MOVE(Texture);
+ static Cache<Texture> cachedTexture;
+
void Bind() const;
private: