Move Texture:generateMipmaps error handling out of backend code

This commit is contained in:
Alex Szpakowski
2020-10-25 23:13:50 -03:00
parent 442f37e0a1
commit e10444c21f
4 changed files with 28 additions and 19 deletions
+16 -1
View File
@@ -487,6 +487,17 @@ void Texture::replacePixels(const void *data, size_t size, int slice, int mipmap
generateMipmaps();
}
void Texture::generateMipmaps()
{
if (getMipmapCount() == 1 || getMipmapsMode() == MIPMAPS_NONE)
throw love::Exception("generateMipmaps can only be called on a Texture which was created with mipmaps enabled.");
if (isPixelFormatCompressed(format))
throw love::Exception("generateMipmaps cannot be called on a compressed Texture.");
generateMipmapsInternal();
}
love::image::ImageData *Texture::newImageData(love::image::Image *module, int slice, int mipmap, const Rect &r)
{
if (!isReadable())
@@ -521,7 +532,11 @@ love::image::ImageData *Texture::newImageData(love::image::Image *module, int sl
throw love::Exception("ImageData with the '%s' pixel format is not supported.", formatname);
}
return module->newImageData(r.w, r.h, dataformat);
auto imagedata = module->newImageData(r.w, r.h, dataformat);
readbackImageData(imagedata, slice, mipmap, r);
return imagedata;
}
TextureType Texture::getTextureType() const