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
+3 -14
View File
@@ -480,14 +480,8 @@ void Texture::uploadByteData(PixelFormat pixelformat, const void *data, size_t s
}
}
void Texture::generateMipmaps()
void Texture::generateMipmapsInternal()
{
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.");
gl.bindTextureToUnit(this, 0, false);
GLenum gltextype = OpenGL::getGLTextureType(texType);
@@ -498,13 +492,10 @@ void Texture::generateMipmaps()
glGenerateMipmap(gltextype);
}
love::image::ImageData *Texture::newImageData(love::image::Image *module, int slice, int mipmap, const Rect &r)
void Texture::readbackImageData(love::image::ImageData *data, int slice, int mipmap, const Rect &r)
{
// Base class does validation (only RTs allowed, etc) and creates ImageData.
love::image::ImageData *data = love::graphics::Texture::newImageData(module, slice, mipmap, r);
if (fbo == 0) // Should never be reached.
return data;
return;
bool isSRGB = false;
OpenGL::TextureFormat fmt = gl.convertPixelFormat(data->getFormat(), false, isSRGB);
@@ -525,8 +516,6 @@ love::image::ImageData *Texture::newImageData(love::image::Image *module, int sl
gl.framebufferTexture(GL_COLOR_ATTACHMENT0, texType, texture, 0, 0, 0);
gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, current_fbo);
return data;
}
void Texture::setSamplerState(const SamplerState &s)
+4 -2
View File
@@ -46,8 +46,6 @@ public:
bool loadVolatile() override;
void unloadVolatile() override;
void generateMipmaps() override;
love::image::ImageData *newImageData(love::image::Image *module, int slice, int mipmap, const Rect &rect) override;
void setSamplerState(const SamplerState &s) override;
ptrdiff_t getHandle() const override;
@@ -62,6 +60,10 @@ private:
void uploadByteData(PixelFormat pixelformat, const void *data, size_t size, int level, int slice, const Rect &r, love::image::ImageDataBase *imgd = nullptr) override;
void generateMipmapsInternal() override;
void readbackImageData(love::image::ImageData *imagedata, int slice, int mipmap, const Rect &rect) override;
Slices slices;
GLuint fbo;