From 8bd40be8aa624be03eac07213ef0fe2fa6578dc5 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Wed, 10 Jun 2015 01:49:12 +0200 Subject: [PATCH] Fix oversight in texture loading that could cause the cape to appear as white blorb. Thx Daxar. --- BBGE/Core.cpp | 15 ++++++++++----- BBGE/Core.h | 2 +- BBGE/RenderObject.cpp | 5 +++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index 4164be9..eb78600 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -4465,14 +4465,18 @@ std::pair, TextureLoadResult> Core::doTextureAdd(const std:: return std::make_pair(t, (TextureLoadResult)res); } -CountedPtr Core::addTexture(const std::string &textureName) +CountedPtr Core::addTexture(const std::string &textureName, TextureLoadResult *pLoadResult /* = 0 */) { - if (textureName.empty()) return NULL; - BBGE_PROF(Core_addTexture); - std::pair, TextureLoadResult> texResult; + if (textureName.empty()) + { + if(pLoadResult) + *pLoadResult = TEX_FAILED; + return NULL; + } + std::pair, TextureLoadResult> texResult; std::string texture = textureName; stringToLowerUserData(texture); std::string internalTextureName = texture; @@ -4513,7 +4517,8 @@ CountedPtr Core::addTexture(const std::string &textureName) debugLog(os.str()); } } - + if(pLoadResult) + *pLoadResult = texResult.second; return texResult.first; } diff --git a/BBGE/Core.h b/BBGE/Core.h index 2f0cd99..fda19c9 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -1023,7 +1023,7 @@ public: void removeTexture(Texture *res); void clearResources(); - CountedPtr addTexture(const std::string &texture); + CountedPtr addTexture(const std::string &texture, TextureLoadResult *pLoadResult = 0); PostProcessingFX postProcessingFx; diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index 6d833cb..5a2f8f8 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -1328,9 +1328,10 @@ bool RenderObject::setTexture(const std::string &n) if(texture && name == texture->name) return true; // no texture change - CountedPtr tex = core->addTexture(name); + TextureLoadResult res = TEX_FAILED; + CountedPtr tex = core->addTexture(name, &res); setTexturePointer(tex); - return !!tex; + return !!tex && res != TEX_FAILED; } float RenderObject::getSortDepth()