diff --git a/include/osg/BlendEquation b/include/osg/BlendEquation index 136e2a59d..0625d89fd 100644 --- a/include/osg/BlendEquation +++ b/include/osg/BlendEquation @@ -107,6 +107,8 @@ class OSG_EXPORT BlendEquation : public StateAttribute void setBlendEquationSupported(bool flag) { _isBlendEquationSupported=flag; } bool isBlendEquationSupported() const { return _isBlendEquationSupported; } + bool isSGIXMinMaxSupported() const { return _isSGIXMinMaxSupported; } + bool isLogicOpSupported() const { return _isLogicOpSupported; } void setBlendEquationProc(void* ptr) { _glBlendEquation = ptr; } void glBlendEquation(GLenum mode) const; @@ -116,6 +118,8 @@ class OSG_EXPORT BlendEquation : public StateAttribute ~Extensions() {} bool _isBlendEquationSupported; + bool _isSGIXMinMaxSupported; + bool _isLogicOpSupported; void* _glBlendEquation; diff --git a/src/osg/BlendEquation.cpp b/src/osg/BlendEquation.cpp index 2ad2ab072..7e7cc052f 100644 --- a/src/osg/BlendEquation.cpp +++ b/src/osg/BlendEquation.cpp @@ -48,6 +48,21 @@ void BlendEquation::apply(State& state) const return; } + GLenum eqn = static_cast(_equation); + + if((eqn == ALPHA_MIN || eqn == ALPHA_MAX) && + !extensions->isSGIXMinMaxSupported()) + { + notify(WARN)<<"Warning: BlendEquation::apply(..) failed, SGIX_blend_alpha_minmax extension is not supported by OpenGL driver." << std::endl; + return; + } + + if(eqn == LOGIC_OP && !extensions->isLogicOpSupported()) + { + notify(WARN)<<"Warning: BlendEquation::apply(..) failed, EXT_blend_logic_op extension is not supported by OpenGL driver." << std::endl; + return; + } + extensions->glBlendEquation(static_cast(_equation)); } @@ -77,6 +92,9 @@ BlendEquation::Extensions::Extensions(const Extensions& rhs): Referenced() { _isBlendEquationSupported = rhs._isBlendEquationSupported; + _isSGIXMinMaxSupported = rhs._isSGIXMinMaxSupported; + _isLogicOpSupported = rhs._isLogicOpSupported; + _glBlendEquation = rhs._glBlendEquation; } void BlendEquation::Extensions::lowestCommonDenominator(const Extensions& rhs) @@ -89,6 +107,9 @@ void BlendEquation::Extensions::setupGLExtenions(unsigned int contextID) { _isBlendEquationSupported = isGLExtensionSupported(contextID,"GL_EXT_blend_equation") || strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; + + _isSGIXMinMaxSupported = isGLExtensionSupported(contextID, "SGIX_blend_alpha_minmax"); + _isLogicOpSupported = isGLExtensionSupported(contextID, "EXT_blend_logic_op"); _glBlendEquation = getGLExtensionFuncPtr("glBlendEquation", "glBlendEquationEXT"); }