X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FTexture.cpp;h=3106c8f31ac4490ff265e24b8faeb1d2b37fe3d4;hb=e08372a2095837a0b951ccb68c3499ef67c1a827;hp=adbef9f7819403a8dcdc16c2fe0d4c56debdb563;hpb=cedb9cffef6e30a2c04239c60027029da48b3897;p=lugaru.git diff --git a/Source/Texture.cpp b/Source/Texture.cpp index adbef9f..3106c8f 100644 --- a/Source/Texture.cpp +++ b/Source/Texture.cpp @@ -21,18 +21,23 @@ along with Lugaru. If not, see . #include "gamegl.h" #include "Texture.h" #include "ImageIO.h" +#include "Utils/Folders.h" using namespace std; -extern ImageRec texture; extern bool trilinear; vector TextureRes::list; void TextureRes::load() { - //load image into 'texture' global var - upload_image(ConvertFileName(filename.c_str())); + ImageRec texture; + + //load image into 'texture' + if (!load_image(filename.c_str(), texture)) { + cerr << "Texture " << filename << " loading failed" << endl; + return; + } skinsize = texture.sizeX; GLuint type = GL_RGBA; @@ -73,8 +78,8 @@ void TextureRes::bind() glBindTexture(GL_TEXTURE_2D, id); } -TextureRes::TextureRes(const string& _filename, bool _hasMipmap, bool _hasAlpha): - id(0), filename(_filename), hasMipmap(_hasMipmap), hasAlpha(_hasAlpha), isSkin(false), +TextureRes::TextureRes(const string& _filename, bool _hasMipmap): + id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(false), skinsize(0), data(NULL), datalen(0) { load(); @@ -82,7 +87,7 @@ TextureRes::TextureRes(const string& _filename, bool _hasMipmap, bool _hasAlpha) } TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep): - id(0), filename(_filename), hasMipmap(_hasMipmap), hasAlpha(false), isSkin(true), + id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(true), skinsize(0), data(NULL), datalen(0) { load(); @@ -103,16 +108,16 @@ TextureRes::~TextureRes() } } -void Texture::load(const string& filename, bool hasMipmap, bool hasAlpha) +void Texture::load(const string& filename, bool hasMipmap) { destroy(); - tex = new TextureRes(filename, hasMipmap, hasAlpha); + tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap); } void Texture::load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep) { destroy(); - tex = new TextureRes(filename, hasMipmap, array, skinsizep); + tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap, array, skinsizep); } void Texture::destroy()