]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Graphic/Texture.cpp
Applied clang-format on all files
[lugaru.git] / Source / Graphic / Texture.cpp
index e2565e9f021af93285c3024bc2f5428b2c27369f..69ff28ed5931727020b143305554da462f5bd0c7 100644 (file)
@@ -27,8 +27,6 @@ using namespace std;
 
 extern bool trilinear;
 
-vector<TextureRes*> TextureRes::list;
-
 void TextureRes::load()
 {
     ImageRec texture;
@@ -78,54 +76,48 @@ void TextureRes::bind()
     glBindTexture(GL_TEXTURE_2D, id);
 }
 
-TextureRes::TextureRes(const string& _filename, bool _hasMipmap):
-    id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(false),
-    skinsize(0), data(NULL), datalen(0)
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap)
+    : id(0)
+    , filename(_filename)
+    , hasMipmap(_hasMipmap)
+    , isSkin(false)
+    , skinsize(0)
+    , data(NULL)
+    , datalen(0)
 {
     load();
-    list.push_back(this);
 }
 
-TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep):
-    id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(true),
-    skinsize(0), data(NULL), datalen(0)
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep)
+    : id(0)
+    , filename(_filename)
+    , hasMipmap(_hasMipmap)
+    , isSkin(true)
+    , skinsize(0)
+    , data(NULL)
+    , datalen(0)
 {
     load();
     *skinsizep = skinsize;
-    for (int i = 0; i < datalen; i++)
+    for (int i = 0; i < datalen; i++) {
         array[i] = data[i];
-    list.push_back(this);
+    }
 }
 
 TextureRes::~TextureRes()
 {
     free(data);
     glDeleteTextures(1, &id);
-    for (vector<TextureRes*>::iterator it = list.begin(); it != list.end(); it++)
-        if (*it == this) {
-            list.erase(it);
-            break;
-        }
 }
 
 void Texture::load(const string& filename, bool hasMipmap)
 {
-    destroy();
-    tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap);
+    tex.reset(new TextureRes(Folders::getResourcePath(filename), hasMipmap));
 }
 
 void Texture::load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep)
 {
-    destroy();
-    tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap, array, skinsizep);
-}
-
-void Texture::destroy()
-{
-    if (tex) {
-        delete tex;
-        tex = NULL;
-    }
+    tex.reset(new TextureRes(Folders::getResourcePath(filename), hasMipmap, array, skinsizep));
 }
 
 void Texture::bind()