- 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; itemLoadAttempted[texSystemId] = true;
} }
Renderer &renderer = Renderer::getInstance(); if(attemptToLoadTexture == true) {
*tex = renderer.newTexture2D(rsGlobal); Renderer &renderer = Renderer::getInstance();
if (*tex) { *tex = renderer.newTexture2D(rsGlobal);
if (*tex) {
(*tex)->setForceCompressionDisabled(compressionDisabled); (*tex)->setForceCompressionDisabled(compressionDisabled);
(*tex)->setMipmap(setMipMap); (*tex)->setMipmap(setMipMap);
if(setAlpha == true) { if(setAlpha == true) {
(*tex)->setFormat(Texture::fAlpha); (*tex)->setFormat(Texture::fAlpha);
(*tex)->getPixmap()->init(1); (*tex)->getPixmap()->init(1);
}
try {
string fileToLoad = uniqueFilePath;
if(loadUniqueFilePath == false) {
fileToLoad = getGameCustomCoreDataPath(data_path,uniqueFilePath);
} }
(*tex)->getPixmap()->load(fileToLoad);
(*tex)->setTextureSystemId(texSystemId);
renderer.initTexture(rsGlobal,*tex); try {
} string fileToLoad = uniqueFilePath;
catch (const megaglest_runtime_error& ex) { if(loadUniqueFilePath == false) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
tempDataLocation); fileToLoad = getGameCustomCoreDataPath(data_path,uniqueFilePath);
cleanupTexture (tex); }
(*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);
}
} }
} }
} }