diff --git a/source/glest_game/facilities/logger.cpp b/source/glest_game/facilities/logger.cpp index 8300a87cf..fe4ffc89a 100644 --- a/source/glest_game/facilities/logger.cpp +++ b/source/glest_game/facilities/logger.cpp @@ -102,8 +102,9 @@ void Logger::loadLoadingScreen(string filepath){ loadingTexture=GraphicsInterface::getInstance().getFactory()->newTexture2D(); //loadingTexture = renderer.newTexture2D(rsGlobal); - loadingTexture->setMipmap(false); - loadingTexture->getPixmap()->load(filepath); + loadingTexture->setMipmap(true); + //loadingTexture->getPixmap()->load(filepath); + loadingTexture->load(filepath); Renderer &renderer= Renderer::getInstance(); renderer.initTexture(rsGlobal,loadingTexture); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index f98b097d0..6cfd70e65 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -107,10 +107,10 @@ void Game::load(){ } // use a scenario based loading screen vector loadScreenList; - findAll(scenarioDir + "/" + "loading_screen.*", loadScreenList, false, false); + findAll(scenarioDir + "loading_screen.*", loadScreenList, false, false); if(loadScreenList.size() > 0) { //string senarioLogo = scenarioDir + "/" + "loading_screen.jpg"; - string senarioLogo = scenarioDir + "/" + loadScreenList[0]; + string senarioLogo = scenarioDir + loadScreenList[0]; if(fileExists(senarioLogo) == true) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found scenario loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str()); diff --git a/source/shared_lib/include/graphics/pixmap.h b/source/shared_lib/include/graphics/pixmap.h index c325d1204..1daa8c49f 100644 --- a/source/shared_lib/include/graphics/pixmap.h +++ b/source/shared_lib/include/graphics/pixmap.h @@ -102,6 +102,7 @@ protected: int w; int components; uint8 *pixels; + string path; public: //constructor & destructor @@ -121,6 +122,7 @@ public: int getW() const {return w;} int getComponents() const {return components;} uint8 *getPixels() const {return pixels;} + string getPath() const { return path;} }; // ===================================================== @@ -133,6 +135,7 @@ protected: int w; int components; uint8 *pixels; + string path; public: //constructor & destructor @@ -193,6 +196,7 @@ public: void lerp(float t, const Pixmap2D *pixmap1, const Pixmap2D *pixmap2); void copy(const Pixmap2D *sourcePixmap); void subCopy(int x, int y, const Pixmap2D *sourcePixmap); + string getPath() const { return path;} private: bool doDimensionsAgree(const Pixmap2D *pixmap); @@ -209,6 +213,7 @@ protected: int d; int components; uint8 *pixels; + string path; public: //constructor & destructor @@ -231,6 +236,7 @@ public: int getD() const {return d;} int getComponents() const {return components;} uint8 *getPixels() const {return pixels;} + string getPath() const { return path;} }; // ===================================================== @@ -250,6 +256,7 @@ public: protected: Pixmap2D faces[6]; + string path[6]; public: //init @@ -264,6 +271,7 @@ public: //get Pixmap2D *getFace(int face) {return &faces[face];} const Pixmap2D *getFace(int face) const {return &faces[face];} + string getPath(int face) const { return path[face];} }; }}//end namespace diff --git a/source/shared_lib/sources/graphics/gl/texture_gl.cpp b/source/shared_lib/sources/graphics/gl/texture_gl.cpp index 8e3eac486..932c72707 100644 --- a/source/shared_lib/sources/graphics/gl/texture_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/texture_gl.cpp @@ -137,7 +137,10 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){ glFormat, GL_UNSIGNED_BYTE, pixels); if(error!=0){ - throw runtime_error("Error building texture 1D mipmaps"); + //throw runtime_error("Error building texture 1D mipmaps"); + char szBuf[1024]=""; + sprintf(szBuf,"Error building texture 1D mipmaps, returned: %d [%s] w = %d",error,pixmap.getPath().c_str(),pixmap.getW()); + throw runtime_error(szBuf); } } else{ @@ -151,7 +154,10 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){ GLint error= glGetError(); if(error!=GL_NO_ERROR){ - throw runtime_error("Error creating texture 1D"); + //throw runtime_error("Error creating texture 1D"); + char szBuf[1024]=""; + sprintf(szBuf,"Error creating texture 1D, returned: %d [%s] w = %d",error,pixmap.getPath().c_str(),pixmap.getW()); + throw runtime_error(szBuf); } } inited= true; @@ -211,7 +217,10 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy){ glFormat, GL_UNSIGNED_BYTE, pixels); if(error!=0){ - throw runtime_error("Error building texture 2D mipmaps"); + //throw runtime_error("Error building texture 2D mipmaps"); + char szBuf[1024]=""; + sprintf(szBuf,"Error building texture 2D mipmaps, returned: %d [%s] w = %d, h = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH()); + throw runtime_error(szBuf); } } else{ @@ -226,7 +235,9 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy){ GLint error= glGetError(); if(error!=GL_NO_ERROR){ - throw runtime_error("Error creating texture 2D"); + char szBuf[1024]=""; + sprintf(szBuf,"Error creating texture 2D, returned: %d [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat); + throw runtime_error(szBuf); } } inited= true; @@ -280,7 +291,10 @@ void Texture3DGl::init(Filter filter, int maxAnisotropy){ GLint error= glGetError(); if(error!=GL_NO_ERROR){ - throw runtime_error("Error creating texture 3D"); + //throw runtime_error("Error creating texture 3D"); + char szBuf[1024]=""; + sprintf(szBuf,"Error creating texture 3D, returned: %d [%s] w = %d, h = %d, d = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),pixmap.getD()); + throw runtime_error(szBuf); } inited= true; } @@ -343,7 +357,10 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy){ glFormat, GL_UNSIGNED_BYTE, pixels); if(error!=0){ - throw runtime_error("Error building texture cube mipmaps"); + //throw runtime_error("Error building texture cube mipmaps"); + char szBuf[1024]=""; + sprintf(szBuf,"Error building texture cube mipmaps, returned: %d [%s] w = %d, h = %d",error,currentPixmap->getPath().c_str(),currentPixmap->getW(),currentPixmap->getH()); + throw runtime_error(szBuf); } } else{ @@ -353,8 +370,12 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy){ 0, glFormat, GL_UNSIGNED_BYTE, pixels); } - if(glGetError()!=GL_NO_ERROR){ - throw runtime_error("Error creating texture cube"); + int error = glGetError(); + if(error!=GL_NO_ERROR){ + //throw runtime_error("Error creating texture cube"); + char szBuf[1024]=""; + sprintf(szBuf,"Error creating texture cube, returned: %d [%s] w = %d, h = %d",error,currentPixmap->getPath().c_str(),currentPixmap->getW(),currentPixmap->getH()); + throw runtime_error(szBuf); } } inited= true; diff --git a/source/shared_lib/sources/graphics/pixmap.cpp b/source/shared_lib/sources/graphics/pixmap.cpp index 29ec12d0a..a6a74fa99 100644 --- a/source/shared_lib/sources/graphics/pixmap.cpp +++ b/source/shared_lib/sources/graphics/pixmap.cpp @@ -356,6 +356,8 @@ Pixmap1D::~Pixmap1D(){ } void Pixmap1D::load(const string &path){ + this->path = path; + string extension= path.substr(path.find_last_of('.')+1); if(extension=="bmp"){ loadBmp(path); @@ -369,6 +371,7 @@ void Pixmap1D::load(const string &path){ } void Pixmap1D::loadBmp(const string &path){ + this->path = path; PixmapIoBmp plb; plb.openRead(path); @@ -396,6 +399,7 @@ void Pixmap1D::loadBmp(const string &path){ } void Pixmap1D::loadTga(const string &path){ + this->path = path; PixmapIoTga plt; plt.openRead(path); @@ -464,10 +468,15 @@ Pixmap2D::~Pixmap2D(){ } Pixmap2D* Pixmap2D::loadPath(const string& path) { - return FileReader::readPath(path); + Pixmap2D *pixmap = FileReader::readPath(path); + if(pixmap != NULL) { + pixmap->path = path; + } + return pixmap; } void Pixmap2D::load(const string &path){ + this->path = path; FileReader::readPath(path,this); } @@ -764,6 +773,8 @@ Pixmap3D::~Pixmap3D(){ } void Pixmap3D::loadSlice(const string &path, int slice){ + this->path = path; + string extension= path.substr(path.find_last_of('.')+1); if(extension=="bmp"){ loadSliceBmp(path, slice); @@ -777,6 +788,7 @@ void Pixmap3D::loadSlice(const string &path, int slice){ } void Pixmap3D::loadSliceBmp(const string &path, int slice){ + this->path = path; PixmapIoBmp plb; plb.openRead(path); @@ -796,6 +808,8 @@ void Pixmap3D::loadSliceBmp(const string &path, int slice){ } void Pixmap3D::loadSliceTga(const string &path, int slice){ + this->path = path; + PixmapIoTga plt; plt.openRead(path); @@ -834,6 +848,8 @@ void PixmapCube::init(int components){ //load & save void PixmapCube::loadFace(const string &path, int face){ + this->path[face] = path; + faces[face].load(path); } diff --git a/source/shared_lib/sources/graphics/texture.cpp b/source/shared_lib/sources/graphics/texture.cpp index 968d8f3e5..8c359cae3 100644 --- a/source/shared_lib/sources/graphics/texture.cpp +++ b/source/shared_lib/sources/graphics/texture.cpp @@ -10,9 +10,12 @@ // ============================================================== #include "texture.h" +#include "util.h" #include "leak_dumper.h" +using namespace Shared::Util; + namespace Shared{ namespace Graphics{ // ===================================================== @@ -37,6 +40,8 @@ Texture::Texture(){ void Texture1D::load(const string &path){ this->path= path; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str()); + if (pixmap.getComponents() == -1) { //TODO: look where you really need that pixmap.init(defaultComponents); } @@ -49,6 +54,8 @@ void Texture1D::load(const string &path){ void Texture2D::load(const string &path){ this->path= path; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str()); + if (pixmap.getComponents() == -1) { pixmap.init(defaultComponents); } @@ -61,6 +68,8 @@ void Texture2D::load(const string &path){ void Texture3D::loadSlice(const string &path, int slice){ this->path= path; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str()); + if (pixmap.getComponents() == -1) { pixmap.init(defaultComponents); } @@ -73,6 +82,8 @@ void Texture3D::loadSlice(const string &path, int slice){ void TextureCube::loadFace(const string &path, int face){ this->path= path; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str()); + if (pixmap.getFace(0)->getComponents() == -1) { pixmap.init(defaultComponents); }