X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGraphic%2FTexture.cpp;h=9dd4ea60be08eac20d5fbc66e04125598944c0b9;hb=4690d99d2bec493f809c7065b222eaf18f46df60;hp=e2565e9f021af93285c3024bc2f5428b2c27369f;hpb=ed3662c0852c4312a612b4fc35bd03aba8d13db7;p=lugaru.git diff --git a/Source/Graphic/Texture.cpp b/Source/Graphic/Texture.cpp index e2565e9..9dd4ea6 100644 --- a/Source/Graphic/Texture.cpp +++ b/Source/Graphic/Texture.cpp @@ -27,8 +27,6 @@ using namespace std; extern bool trilinear; -vector TextureRes::list; - void TextureRes::load() { ImageRec texture; @@ -83,7 +81,6 @@ TextureRes::TextureRes(const string& _filename, bool _hasMipmap): skinsize(0), data(NULL), datalen(0) { load(); - list.push_back(this); } TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep): @@ -92,40 +89,25 @@ TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, { 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::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()