- small bugfix for lazy loading textures

This commit is contained in:
SoftCoder 2013-12-27 22:08:51 -08:00
parent 62821793c0
commit c442328b58
1 changed files with 25 additions and 23 deletions

View File

@ -206,33 +206,35 @@ void CoreData::loadTextureIfRequired(Texture2D **tex,string data_path,
itemLoadAttempted[texSystemId] = true;
}
Renderer &renderer = Renderer::getInstance();
*tex = renderer.newTexture2D(rsGlobal);
if (*tex) {
if(attemptToLoadTexture == true) {
Renderer &renderer = Renderer::getInstance();
*tex = renderer.newTexture2D(rsGlobal);
if (*tex) {
(*tex)->setForceCompressionDisabled(compressionDisabled);
(*tex)->setMipmap(setMipMap);
if(setAlpha == true) {
(*tex)->setForceCompressionDisabled(compressionDisabled);
(*tex)->setMipmap(setMipMap);
if(setAlpha == true) {
(*tex)->setFormat(Texture::fAlpha);
(*tex)->getPixmap()->init(1);
}
try {
string fileToLoad = uniqueFilePath;
if(loadUniqueFilePath == false) {
fileToLoad = getGameCustomCoreDataPath(data_path,uniqueFilePath);
(*tex)->setFormat(Texture::fAlpha);
(*tex)->getPixmap()->init(1);
}
(*tex)->getPixmap()->load(fileToLoad);
(*tex)->setTextureSystemId(texSystemId);
renderer.initTexture(rsGlobal,*tex);
}
catch (const megaglest_runtime_error& ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
tempDataLocation);
cleanupTexture (tex);
try {
string fileToLoad = uniqueFilePath;
if(loadUniqueFilePath == false) {
fileToLoad = getGameCustomCoreDataPath(data_path,uniqueFilePath);
}
(*tex)->getPixmap()->load(fileToLoad);
(*tex)->setTextureSystemId(texSystemId);
renderer.initTexture(rsGlobal,*tex);
}
catch (const megaglest_runtime_error& ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
tempDataLocation);
cleanupTexture (tex);
}
}
}
}