diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index e7d0ddb69..4583c3a9f 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -1986,6 +1986,8 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat) flags |= commonsample; if (GLAD_EXT_color_buffer_half_float && (GLAD_ES_VERSION_3_0 || GLAD_EXT_texture_rg)) flags |= commonrender; + if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear)) + flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR; break; case PIXELFORMAT_RGBA16_FLOAT: if (GLAD_VERSION_3_0 || (GLAD_VERSION_1_0 && GLAD_ARB_texture_float && GLAD_ARB_half_float_pixel)) @@ -1994,6 +1996,8 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat) flags |= commonsample; if (GLAD_EXT_color_buffer_half_float) flags |= commonrender; + if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear)) + flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR; break; case PIXELFORMAT_R32_FLOAT: case PIXELFORMAT_RG32_FLOAT: @@ -2001,12 +2005,16 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat) flags |= commonsample | commonrender; if (GLAD_ES_VERSION_3_0 || (GLAD_OES_texture_float && GLAD_EXT_texture_rg)) flags |= commonsample; + if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear)) + flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR; break; case PIXELFORMAT_RGBA32_FLOAT: if (GLAD_VERSION_3_0 || (GLAD_VERSION_1_0 && GLAD_ARB_texture_float)) flags |= commonsample | commonrender; if (GLAD_ES_VERSION_3_0 || GLAD_OES_texture_float) flags |= commonsample; + if (!(GLAD_VERSION_1_1 || GLAD_OES_texture_float_linear)) + flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR; break; case PIXELFORMAT_LA8_UNORM: @@ -2139,23 +2147,6 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat) return flags; } -bool OpenGL::hasTextureFilteringSupport(PixelFormat pixelformat) -{ - switch (pixelformat) - { - case PIXELFORMAT_R16_FLOAT: - case PIXELFORMAT_RG16_FLOAT: - case PIXELFORMAT_RGBA16_FLOAT: - return GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear; - case PIXELFORMAT_R32_FLOAT: - case PIXELFORMAT_RG32_FLOAT: - case PIXELFORMAT_RGBA32_FLOAT: - return GLAD_VERSION_1_1 || GLAD_OES_texture_float_linear; - default: - return true; - } -} - const char *OpenGL::errorString(GLenum errorcode) { switch (errorcode) diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index 48f43f516..b964896a4 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -444,7 +444,6 @@ public: static TextureFormat convertPixelFormat(PixelFormat pixelformat, bool renderbuffer, bool &isSRGB); static bool isTexStorageSupported(); static uint32 getPixelFormatUsageFlags(PixelFormat pixelformat); - static bool hasTextureFilteringSupport(PixelFormat pixelformat); static const char *errorString(GLenum errorcode); static const char *framebufferStatusString(GLenum status); diff --git a/src/modules/graphics/opengl/Texture.cpp b/src/modules/graphics/opengl/Texture.cpp index 2d7c8a62f..bef283dde 100644 --- a/src/modules/graphics/opengl/Texture.cpp +++ b/src/modules/graphics/opengl/Texture.cpp @@ -539,7 +539,9 @@ void Texture::setSamplerState(const SamplerState &s) // Base class does common validation and assigns samplerState. love::graphics::Texture::setSamplerState(s); - if (!OpenGL::hasTextureFilteringSupport(getPixelFormat())) + auto supportedflags = OpenGL::getPixelFormatUsageFlags(getPixelFormat()); + + if ((supportedflags & PIXELFORMATUSAGEFLAGS_LINEAR) == 0) { samplerState.magFilter = samplerState.minFilter = SamplerState::FILTER_NEAREST;