mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Cleaned up love.graphics Image code for determining whether the image's pixel format is supported.
This commit is contained in:
@@ -1398,9 +1398,9 @@ bool Graphics::isCanvasFormatSupported(PixelFormat format, bool readable) const
|
||||
return Canvas::isFormatSupported(format, readable);
|
||||
}
|
||||
|
||||
bool Graphics::isImageFormatSupported(PixelFormat format) const
|
||||
bool Graphics::isImageFormatSupported(PixelFormat format, bool sRGB) const
|
||||
{
|
||||
return Image::isFormatSupported(format);
|
||||
return Image::isFormatSupported(format, sRGB);
|
||||
}
|
||||
|
||||
Shader::Language Graphics::getShaderLanguageTarget() const
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
|
||||
bool isCanvasFormatSupported(PixelFormat format) const override;
|
||||
bool isCanvasFormatSupported(PixelFormat format, bool readable) const override;
|
||||
bool isImageFormatSupported(PixelFormat format) const override;
|
||||
bool isImageFormatSupported(PixelFormat format, bool sRGB) const override;
|
||||
Renderer getRenderer() const override;
|
||||
RendererInfo getRendererInfo() const override;
|
||||
|
||||
|
||||
@@ -185,22 +185,8 @@ bool Image::loadVolatile()
|
||||
|
||||
OpenGL::TempDebugGroup debuggroup("Image load");
|
||||
|
||||
if (!OpenGL::isPixelFormatSupported(format, false, true, sRGB))
|
||||
if (!isCompressed())
|
||||
{
|
||||
const char *str;
|
||||
if (love::getConstant(format, 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.");
|
||||
}
|
||||
else if (!isCompressed())
|
||||
{
|
||||
if (sRGB && !hasSRGBSupport())
|
||||
throw love::Exception("sRGB images are not supported on this system.");
|
||||
|
||||
// GL_EXT_sRGB doesn't support glGenerateMipmap for sRGB textures.
|
||||
if (sRGB && (GLAD_ES_VERSION_2_0 && GLAD_EXT_sRGB && !GLAD_ES_VERSION_3_0)
|
||||
&& mipmapsType != MIPMAPS_DATA)
|
||||
@@ -365,14 +351,9 @@ bool Image::setMipmapSharpness(float sharpness)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Image::isFormatSupported(PixelFormat pixelformat)
|
||||
bool Image::isFormatSupported(PixelFormat pixelformat, bool sRGB)
|
||||
{
|
||||
return OpenGL::isPixelFormatSupported(pixelformat, false, true, false);
|
||||
}
|
||||
|
||||
bool Image::hasSRGBSupport()
|
||||
{
|
||||
return GLAD_ES_VERSION_3_0 || GLAD_EXT_sRGB || GLAD_VERSION_2_1 || GLAD_EXT_texture_sRGB;
|
||||
return OpenGL::isPixelFormatSupported(pixelformat, false, true, sRGB);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -54,8 +54,7 @@ public:
|
||||
|
||||
bool setMipmapSharpness(float sharpness) override;
|
||||
|
||||
static bool isFormatSupported(PixelFormat pixelformat);
|
||||
static bool hasSRGBSupport();
|
||||
static bool isFormatSupported(PixelFormat pixelformat, bool sRGB);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user