This commit is contained in:
Eduardo Bart
2011-05-01 15:51:46 -03:00
5 changed files with 30 additions and 20 deletions

View File

@@ -47,7 +47,8 @@ Image::Image(const std::string& texture, Rect textureCoords) :
void Image::draw(const Rect& screenCoords)
{
g_graphics.drawTexturedRect(screenCoords, m_texture, m_textureCoords);
if(m_texture)
g_graphics.drawTexturedRect(screenCoords, m_texture, m_textureCoords);
}

View File

@@ -45,19 +45,24 @@ TexturePtr Textures::get(const std::string& textureFile)
// texture not found, load it
if(!texture) {
// currently only png textures are supported
if(!boost::ends_with(textureFile, ".png"))
flogFatal("FATAL ERROR: Unable to load texture %s, file format no supported.", textureFile.c_str());
if(!boost::ends_with(textureFile, ".png")) {
flogError("ERROR: Unable to load texture %s, file format no supported.", textureFile.c_str());
return texture;
}
// load texture file data
uint fileSize;
uchar *textureFileData = g_resources.loadFile(textureFile, &fileSize);
if(!textureFileData)
flogFatal("FATAL ERROR: Unable to load texture %s, file could not be read.", textureFile.c_str());
if(!textureFileData) {
flogError("ERROR: Unable to load texture %s, file could not be read.", textureFile.c_str());
return texture;
}
// load the texture
texture = TexturePtr(TextureLoader::loadPNG(textureFileData));
if(!texture)
flogFatal("FATAL ERROR: Unable to load texture %s", textureFile.c_str());
flogError("ERROR: Unable to load texture %s", textureFile.c_str());
delete[] textureFileData;
}