]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Graphic/Texture.hpp
clang-format: Apply to all headers
[lugaru.git] / Source / Graphic / Texture.hpp
index ab51cdb9653cf760fda40430c57fa60daeed262f..b47ab1cb1cb6d6c219cfe771f2747a9804bd1e6b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file)
 
 This file is part of Lugaru.
 
@@ -24,16 +24,13 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include "Graphic/gamegl.hpp"
 
 #include <map>
+#include <memory>
 #include <string>
 #include <vector>
 
-using namespace std;
-
 class TextureRes
 {
 private:
-    static vector<TextureRes*> list;
-
     GLuint id;
     string filename;
     bool hasMipmap;
@@ -49,17 +46,24 @@ public:
     TextureRes(const string& filename, bool hasMipmap, GLubyte* array, int* skinsize);
     ~TextureRes();
     void bind();
+
+    /* Make sure TextureRes never gets copied */
+    TextureRes(TextureRes const& other) = delete;
+    TextureRes& operator=(TextureRes const& other) = delete;
 };
 
 class Texture
 {
 private:
-    TextureRes* tex;
+    std::shared_ptr<TextureRes> tex;
+
 public:
-    inline Texture(): tex(NULL) {}
+    inline Texture()
+        : tex(nullptr)
+    {
+    }
     void load(const string& filename, bool hasMipmap);
     void load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep);
-    void destroy();
     void bind();
 };