diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 345e0113f..ac77daae8 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -156,6 +156,7 @@ namespace graphics { "canvas", Graphics::SUPPORT_CANVAS }, { "pixeleffect", Graphics::SUPPORT_PIXELEFFECT }, { "npot", Graphics::SUPPORT_NPOT }, + { "subtractive", Graphics::SUPPORT_SUBTRACTIVE }, }; StringMap Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries)); diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index bb4a64be8..943f2e7d8 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -85,6 +85,7 @@ namespace graphics SUPPORT_CANVAS = 1, SUPPORT_PIXELEFFECT, SUPPORT_NPOT, + SUPPORT_SUBTRACTIVE, SUPPORT_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index b357c8ca8..98629899e 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -511,10 +511,24 @@ namespace opengl { glAlphaFunc(GL_GEQUAL, 0); - if (mode == BLEND_SUBTRACTIVE) - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); - else - glBlendEquation(GL_FUNC_ADD); + if (GLEE_VERSION_1_4 || GLEE_ARB_imaging) { + if (mode == BLEND_SUBTRACTIVE) { + glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + } else { + glBlendEquation(GL_FUNC_ADD); + } + } else if (GLEE_EXT_blend_minmax && GLEE_EXT_blend_subtract) { + if (mode == BLEND_SUBTRACTIVE) { + glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); + } else { + glBlendEquationEXT(GL_FUNC_ADD_EXT); + } + } else { + if (mode == BLEND_SUBTRACTIVE) { + std::cerr << "This graphics card does not support the subtract blend mode!" << std::endl; + } + // GL_FUNC_ADD is the default even without access to glBlendEquation, so that'll still work. + } if (mode == BLEND_ALPHA) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index d98407697..8ece980f8 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -19,6 +19,7 @@ **/ #include "wrap_Graphics.h" +#include "GLee.h" #include #include #include @@ -793,6 +794,9 @@ namespace opengl if (!Image::hasNpot()) supported = false; break; + case Graphics::SUPPORT_SUBTRACTIVE: + supported = (GLEE_VERSION_1_4 || GLEE_ARB_imaging) || (GLEE_EXT_blend_minmax && GLEE_EXT_blend_subtract); + break; default: supported = false; }