Cleaned up love.graphics Image code for determining whether the image's pixel format is supported.

This commit is contained in:
Alex Szpakowski
2019-01-16 19:30:21 -04:00
parent 1bb50fccac
commit 74dcc41b38
6 changed files with 23 additions and 30 deletions
+15 -2
View File
@@ -43,8 +43,6 @@ Image::Image(const Slices &data, const Settings &settings, bool validatedata)
{
if (validatedata && data.validate() == MIPMAPS_DATA)
mipmapsType = MIPMAPS_DATA;
++imageCount;
}
Image::Image(TextureType textype, PixelFormat format, int width, int height, int slices, const Settings &settings)
@@ -80,6 +78,19 @@ Image::~Image()
void Image::init(PixelFormat fmt, int w, int h, const Settings &settings)
{
Graphics *gfx = Module::getInstance<Graphics>(Module::M_GRAPHICS);
if (gfx != nullptr && !gfx->isImageFormatSupported(fmt, sRGB))
{
const char *str;
if (love::getConstant(fmt, str))
{
throw love::Exception("Cannot create image: "
"%s%s images are not supported on this system.", sRGB ? "sRGB " : "", str);
}
else
throw love::Exception("cannot create image: format is not supported on this system.");
}
pixelWidth = w;
pixelHeight = h;
@@ -97,6 +108,8 @@ void Image::init(PixelFormat fmt, int w, int h, const Settings &settings)
filter.mipmap = defaultMipmapFilter;
initQuad();
++imageCount;
}
void Image::uploadImageData(love::image::ImageDataBase *d, int level, int slice, int x, int y)