From 1f15fd0805766b0ef87c894a06d2aba6cba66f7b Mon Sep 17 00:00:00 2001 From: numzero Date: Thu, 20 Apr 2023 17:44:14 +0300 Subject: [PATCH] OpenGL3: Support min/max blend modes --- source/Irrlicht/OpenGL/Driver.cpp | 12 ++++++++++++ source/Irrlicht/OpenGL/ExtensionHandler.h | 1 + source/Irrlicht/OpenGL3/Driver.cpp | 1 + source/Irrlicht/OpenGLES2/Driver.cpp | 1 + 4 files changed, 15 insertions(+) diff --git a/source/Irrlicht/OpenGL/Driver.cpp b/source/Irrlicht/OpenGL/Driver.cpp index cb9f5ca..8994be6 100644 --- a/source/Irrlicht/OpenGL/Driver.cpp +++ b/source/Irrlicht/OpenGL/Driver.cpp @@ -1405,6 +1405,18 @@ COpenGL3DriverBase::~COpenGL3DriverBase() case EBO_REVSUBTRACT: CacheHandler->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT); break; + case EBO_MIN: + if (BlendMinMaxSupported) + CacheHandler->setBlendEquation(GL_MIN); + else + os::Printer::log("Attempt to use EBO_MIN without driver support", ELL_WARNING); + break; + case EBO_MAX: + if (BlendMinMaxSupported) + CacheHandler->setBlendEquation(GL_MAX); + else + os::Printer::log("Attempt to use EBO_MAX without driver support", ELL_WARNING); + break; default: break; } diff --git a/source/Irrlicht/OpenGL/ExtensionHandler.h b/source/Irrlicht/OpenGL/ExtensionHandler.h index 9645823..57106f0 100644 --- a/source/Irrlicht/OpenGL/ExtensionHandler.h +++ b/source/Irrlicht/OpenGL/ExtensionHandler.h @@ -166,6 +166,7 @@ namespace video } bool AnisotropicFilterSupported = false; + bool BlendMinMaxSupported = false; private: void addExtension(std::string name); diff --git a/source/Irrlicht/OpenGL3/Driver.cpp b/source/Irrlicht/OpenGL3/Driver.cpp index 4165004..6657479 100644 --- a/source/Irrlicht/OpenGL3/Driver.cpp +++ b/source/Irrlicht/OpenGL3/Driver.cpp @@ -34,6 +34,7 @@ namespace video { initExtensionsNew(); AnisotropicFilterSupported = isVersionAtLeast(4, 6) || queryExtension("GL_ARB_texture_filter_anisotropic") || queryExtension("GL_EXT_texture_filter_anisotropic"); + BlendMinMaxSupported = true; // COGLESCoreExtensionHandler::Feature static_assert(MATERIAL_MAX_TEXTURES <= 16, "Only up to 16 textures are guaranteed"); diff --git a/source/Irrlicht/OpenGLES2/Driver.cpp b/source/Irrlicht/OpenGLES2/Driver.cpp index c899a7b..5766e8a 100644 --- a/source/Irrlicht/OpenGLES2/Driver.cpp +++ b/source/Irrlicht/OpenGLES2/Driver.cpp @@ -32,6 +32,7 @@ namespace video { const bool MRTSupported = Version.Major >= 3 || queryExtension("GL_EXT_draw_buffers"); AnisotropicFilterSupported = queryExtension("GL_EXT_texture_filter_anisotropic"); + BlendMinMaxSupported = (Version.Major >= 3) || FeatureAvailable[IRR_GL_EXT_blend_minmax]; const bool TextureLODBiasSupported = queryExtension("GL_EXT_texture_lod_bias"); // COGLESCoreExtensionHandler::Feature