Commit 995f2bd7 authored by nadro's avatar nadro

- Minor fixes in blend operation mechanism.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4783 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9c3e0d6b
...@@ -637,7 +637,6 @@ COpenGLDriver::~COpenGLDriver() ...@@ -637,7 +637,6 @@ COpenGLDriver::~COpenGLDriver()
cgDestroyContext(CgContext); cgDestroyContext(CgContext);
#endif #endif
if (BridgeCalls)
delete BridgeCalls; delete BridgeCalls;
RequestedLights.clear(); RequestedLights.clear();
...@@ -3095,51 +3094,46 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -3095,51 +3094,46 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
(material.ColorMask & ECP_ALPHA)?GL_TRUE:GL_FALSE); (material.ColorMask & ECP_ALPHA)?GL_TRUE:GL_FALSE);
} }
if (queryFeature(EVDF_BLEND_OPERATIONS) && // Blend Equation
(resetAllRenderStates|| lastmaterial.BlendOperation != material.BlendOperation)) if (resetAllRenderStates|| lastmaterial.BlendOperation != material.BlendOperation)
{ {
if (material.BlendOperation==EBO_NONE) if (material.BlendOperation==EBO_NONE)
BridgeCalls->setBlend(false); BridgeCalls->setBlend(false);
else else
{ {
BridgeCalls->setBlend(true); BridgeCalls->setBlend(true);
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) || defined(GL_VERSION_1_2)
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) || defined(GL_VERSION_1_4)
if (queryFeature(EVDF_BLEND_OPERATIONS))
{
switch (material.BlendOperation) switch (material.BlendOperation)
{ {
case EBO_SUBTRACT: case EBO_SUBTRACT:
#if defined(GL_EXT_blend_subtract) #if defined(GL_VERSION_1_4)
if (FeatureAvailable[IRR_EXT_blend_subtract] || (Version>=120))
BridgeCalls->setBlendEquation(GL_FUNC_SUBTRACT_EXT);
#elif defined(GL_VERSION_1_2)
if (Version>=120)
BridgeCalls->setBlendEquation(GL_FUNC_SUBTRACT); BridgeCalls->setBlendEquation(GL_FUNC_SUBTRACT);
#elif defined(GL_EXT_blend_subtract)
BridgeCalls->setBlendEquation(GL_FUNC_SUBTRACT_EXT);
#endif #endif
break; break;
case EBO_REVSUBTRACT: case EBO_REVSUBTRACT:
#if defined(GL_EXT_blend_subtract) #if defined(GL_VERSION_1_4)
if (FeatureAvailable[IRR_EXT_blend_subtract] || (Version>=120))
BridgeCalls->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT_EXT);
#elif defined(GL_VERSION_1_2)
if (Version>=120)
BridgeCalls->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT); BridgeCalls->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
#elif defined(GL_EXT_blend_subtract)
BridgeCalls->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT_EXT);
#endif #endif
break; break;
case EBO_MIN: case EBO_MIN:
#if defined(GL_EXT_blend_minmax) #if defined(GL_VERSION_1_4)
if (FeatureAvailable[IRR_EXT_blend_minmax] || (Version>=120))
BridgeCalls->setBlendEquation(GL_MIN_EXT);
#elif defined(GL_VERSION_1_2)
if (Version>=120)
BridgeCalls->setBlendEquation(GL_MIN); BridgeCalls->setBlendEquation(GL_MIN);
#elif defined(GL_EXT_blend_minmax)
BridgeCalls->setBlendEquation(GL_MIN_EXT);
#endif #endif
break; break;
case EBO_MAX: case EBO_MAX:
#if defined(GL_EXT_blend_minmax) #if defined(GL_VERSION_1_4)
if (FeatureAvailable[IRR_EXT_blend_minmax] || (Version>=120))
BridgeCalls->setBlendEquation(GL_MAX_EXT);
#elif defined(GL_VERSION_1_2)
if (Version>=120)
BridgeCalls->setBlendEquation(GL_MAX); BridgeCalls->setBlendEquation(GL_MAX);
#elif defined(GL_EXT_blend_minmax)
BridgeCalls->setBlendEquation(GL_MAX_EXT);
#endif #endif
break; break;
case EBO_MIN_FACTOR: case EBO_MIN_FACTOR:
...@@ -3148,11 +3142,10 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -3148,11 +3142,10 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
BridgeCalls->setBlendEquation(GL_FACTOR_MIN_AMD); BridgeCalls->setBlendEquation(GL_FACTOR_MIN_AMD);
#endif #endif
// fallback in case of missing extension // fallback in case of missing extension
#if defined(GL_VERSION_1_2) #if defined(GL_VERSION_1_4)
#if defined(GL_AMD_blend_minmax_factor) #if defined(GL_AMD_blend_minmax_factor)
else else
#endif #endif
if (Version>=120)
BridgeCalls->setBlendEquation(GL_MIN); BridgeCalls->setBlendEquation(GL_MIN);
#endif #endif
break; break;
...@@ -3162,11 +3155,10 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -3162,11 +3155,10 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
BridgeCalls->setBlendEquation(GL_FACTOR_MAX_AMD); BridgeCalls->setBlendEquation(GL_FACTOR_MAX_AMD);
#endif #endif
// fallback in case of missing extension // fallback in case of missing extension
#if defined(GL_VERSION_1_2) #if defined(GL_VERSION_1_4)
#if defined(GL_AMD_blend_minmax_factor) #if defined(GL_AMD_blend_minmax_factor)
else else
#endif #endif
if (Version>=120)
BridgeCalls->setBlendEquation(GL_MAX); BridgeCalls->setBlendEquation(GL_MAX);
#endif #endif
break; break;
...@@ -3191,15 +3183,14 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -3191,15 +3183,14 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
#endif #endif
break; break;
default: default:
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) #if defined(GL_VERSION_1_4)
if (Version>=120)
BridgeCalls->setBlendEquation(GL_FUNC_ADD_EXT);
#elif defined(GL_VERSION_1_2)
if (Version>=120)
BridgeCalls->setBlendEquation(GL_FUNC_ADD); BridgeCalls->setBlendEquation(GL_FUNC_ADD);
#elif defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op)
BridgeCalls->setBlendEquation(GL_FUNC_ADD_EXT);
#endif #endif
break; break;
} }
}
#endif #endif
} }
} }
...@@ -5060,10 +5051,10 @@ COpenGLCallBridge::COpenGLCallBridge(COpenGLDriver* driver) : Driver(driver), ...@@ -5060,10 +5051,10 @@ COpenGLCallBridge::COpenGLCallBridge(COpenGLDriver* driver) : Driver(driver),
for (u32 i = 0; i < BlendIndexCount; ++i) for (u32 i = 0; i < BlendIndexCount; ++i)
{ {
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) #if defined(GL_VERSION_1_4)
BlendEquation[i] = GL_FUNC_ADD_EXT;
#elif defined(GL_VERSION_1_2)
BlendEquation[i] = GL_FUNC_ADD; BlendEquation[i] = GL_FUNC_ADD;
#elif defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op)
BlendEquation[i] = GL_FUNC_ADD_EXT;
#endif #endif
BlendSource[i] = GL_ONE; BlendSource[i] = GL_ONE;
...@@ -5083,13 +5074,14 @@ COpenGLCallBridge::COpenGLCallBridge(COpenGLDriver* driver) : Driver(driver), ...@@ -5083,13 +5074,14 @@ COpenGLCallBridge::COpenGLCallBridge(COpenGLDriver* driver) : Driver(driver),
glAlphaFunc(GL_ALWAYS, 0.0f); glAlphaFunc(GL_ALWAYS, 0.0f);
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) if (Driver->queryFeature(EVDF_BLEND_OPERATIONS))
if (Driver->Version >= 120) {
Driver->extGlBlendEquation(GL_FUNC_ADD_EXT); #if defined(GL_VERSION_1_4)
#elif defined(GL_VERSION_1_2)
if (Driver->Version >= 120)
Driver->extGlBlendEquation(GL_FUNC_ADD); Driver->extGlBlendEquation(GL_FUNC_ADD);
#elif defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op)
Driver->extGlBlendEquation(GL_FUNC_ADD_EXT);
#endif #endif
}
glBlendFunc(GL_ONE, GL_ZERO); glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND); glDisable(GL_BLEND);
......
...@@ -785,7 +785,7 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const ...@@ -785,7 +785,7 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
// both features supported with OpenGL 1.1 // both features supported with OpenGL 1.1
return Version>=110; return Version>=110;
case EVDF_BLEND_OPERATIONS: case EVDF_BLEND_OPERATIONS:
return (Version>=120) || FeatureAvailable[IRR_EXT_blend_minmax] || return (Version>=140) || FeatureAvailable[IRR_EXT_blend_minmax] ||
FeatureAvailable[IRR_EXT_blend_subtract] || FeatureAvailable[IRR_EXT_blend_logic_op]; FeatureAvailable[IRR_EXT_blend_subtract] || FeatureAvailable[IRR_EXT_blend_logic_op];
case EVDF_TEXTURE_MATRIX: case EVDF_TEXTURE_MATRIX:
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment