From 501beb7d023caffc425b39aeb20f30c7c370a4ec Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Fri, 18 Jan 2013 00:48:36 +0100 Subject: [PATCH] Add blend mode 'none' (issue #536) --- src/modules/graphics/Graphics.cpp | 1 + src/modules/graphics/Graphics.h | 1 + src/modules/graphics/opengl/Graphics.cpp | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 58019c017..c29896bad 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -124,6 +124,7 @@ StringMap::Entry Graphics::blendM { "subtractive", Graphics::BLEND_SUBTRACTIVE }, { "multiplicative", Graphics::BLEND_MULTIPLICATIVE }, { "premultiplied", Graphics::BLEND_PREMULTIPLIED }, + { "none", Graphics::BLEND_NONE }, }; StringMap Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries)); diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 4926aa90a..2480184f9 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -57,6 +57,7 @@ public: BLEND_SUBTRACTIVE, BLEND_MULTIPLICATIVE, BLEND_PREMULTIPLIED, + BLEND_NONE, BLEND_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 182deccc4..f33cb3eb0 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -549,6 +549,8 @@ void Graphics::setBlendMode(Graphics::BlendMode mode) glBlendFunc(GL_DST_COLOR, GL_ZERO); else if (mode == BLEND_PREMULTIPLIED) glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + else if (mode == BLEND_NONE) + glBlendFunc(GL_ONE, GL_ZERO); else // mode == BLEND_ADDITIVE || mode == BLEND_SUBTRACTIVE glBlendFunc(GL_SRC_ALPHA, GL_ONE); } @@ -584,6 +586,8 @@ Graphics::BlendMode Graphics::getBlendMode() return BLEND_MULTIPLICATIVE; else if (src == GL_ONE && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD return BLEND_PREMULTIPLIED; + else if (src == GL_ONE && dst == GL_ZERO) + return BLEND_NONE; return BLEND_MAX_ENUM; // Should never be reached. }