mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Move Texture:generateMipmaps error handling out of backend code
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user