extern bool trilinear;
-vector<TextureRes*> TextureRes::list;
-
void TextureRes::load()
{
ImageRec texture;
skinsize(0), data(NULL), datalen(0)
{
load();
- list.push_back(this);
}
TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep):
{
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()