From Ravi Mathur, "Here is an update to BlendEquation that adds checking for the
SGIX_blend_alpha_minmax and EXT_blend_logic_op extensions. It is tested with the osgblendequation example. If the extensions are not supported, a WARN level notification is generated."
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -48,6 +48,21 @@ void BlendEquation::apply(State& state) const
|
||||
return;
|
||||
}
|
||||
|
||||
GLenum eqn = static_cast<GLenum>(_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<GLenum>(_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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user