Skip to content

Commit

Permalink
GRAPHICS: Add some extra sanity checks when loading images
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Mar 20, 2014
1 parent c2191f5 commit ca4a69c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/graphics/textureman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,12 @@ void TextureManager::convert(Ogre::TexturePtr &texture, const ImageDecoder &imag
if (Ogre::PixelUtil::isCompressed(formatFrom) != Ogre::PixelUtil::isCompressed(formatTo))
throw Common::Exception("Can't convert between compressed and non-compressed pixel formats");

if (Ogre::PixelUtil::isCompressed(formatFrom) && (formatFrom != formatTo))
throw Common::Exception("Can't convert between different compressed pixel formats");

// OGRE segfaults when using bulkPixelConversion() to copy compressed formats
if (Ogre::PixelUtil::isCompressed(formatFrom))
memcpy(dst, src, mipMap.size);
memcpy(dst, src, MIN<uint32>(mipMap.size, buffer->getSizeInBytes()));
else
// TODO: This is probably really slow...
Ogre::PixelUtil::bulkPixelConversion(src, formatFrom, dst, formatTo, pixels);
Expand Down

0 comments on commit ca4a69c

Please sign in to comment.