Added “none” blend mode. This is equivalent to setBlendMode(“replace”, “premultiplied”) (which also effectively disables blending) but doesn’t require explicitly setting the alpha multiplication mode.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-12-28 12:32:37 -04:00
parent 4ef91ed79f
commit a78fa39113
4 changed files with 6 additions and 3 deletions
+1
View File
@@ -610,6 +610,7 @@ StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM>::Entry Graphics::blendM
{ "darken", BLEND_DARKEN },
{ "screen", BLEND_SCREEN },
{ "replace", BLEND_REPLACE },
{ "none", BLEND_NONE },
};
StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM> Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries));
+1
View File
@@ -97,6 +97,7 @@ public:
BLEND_DARKEN,
BLEND_SCREEN,
BLEND_REPLACE,
BLEND_NONE,
BLEND_MAX_ENUM
};
+2 -1
View File
@@ -1602,6 +1602,7 @@ void Graphics::setBlendMode(BlendMode mode, BlendAlpha alphamode)
dstRGB = dstA = GL_ONE_MINUS_SRC_COLOR;
break;
case BLEND_REPLACE:
case BLEND_NONE:
default:
srcRGB = srcA = GL_ONE;
dstRGB = dstA = GL_ZERO;
@@ -1609,7 +1610,7 @@ void Graphics::setBlendMode(BlendMode mode, BlendAlpha alphamode)
}
// We can only do alpha-multiplication when srcRGB would have been unmodified.
if (srcRGB == GL_ONE && alphamode == BLENDALPHA_MULTIPLY)
if (srcRGB == GL_ONE && alphamode == BLENDALPHA_MULTIPLY && mode != BLEND_NONE)
srcRGB = GL_SRC_ALPHA;
glBlendEquation(func);