From 146b3cff19870dfb2d1853eec4f7376c0137b1bb Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Thu, 27 Mar 2014 23:28:36 -0300 Subject: [PATCH] Added blend mode "screen". --- src/modules/graphics/Graphics.cpp | 1 + src/modules/graphics/Graphics.h | 1 + src/modules/graphics/opengl/Graphics.cpp | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 10f8cf8e1..516c8530c 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -144,6 +144,7 @@ StringMap::Entry Graphics::blendM { "subtractive", Graphics::BLEND_SUBTRACTIVE }, { "multiplicative", Graphics::BLEND_MULTIPLICATIVE }, { "premultiplied", Graphics::BLEND_PREMULTIPLIED }, + { "screen", Graphics::BLEND_SCREEN }, { "replace", Graphics::BLEND_REPLACE }, }; diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index e91d96e8f..95406e485 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_SCREEN, BLEND_REPLACE, BLEND_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 3630e3216..80a0c3026 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -642,6 +642,10 @@ void Graphics::setBlendMode(Graphics::BlendMode mode) state.srcRGB = state.srcA = GL_SRC_ALPHA; state.dstRGB = state.dstA = GL_ONE; break; + case BLEND_SCREEN: + state.srcRGB = state.srcA = GL_ONE; + state.dstRGB = state.dstA = GL_ONE_MINUS_SRC_COLOR; + break; case BLEND_REPLACE: default: state.srcRGB = state.srcA = GL_ONE; @@ -669,6 +673,8 @@ Graphics::BlendMode Graphics::getBlendMode() const return BLEND_MULTIPLICATIVE; else if (state.srcRGB == GL_ONE && state.dstRGB == GL_ONE_MINUS_SRC_ALPHA) return BLEND_PREMULTIPLIED; + else if (state.srcRGB == GL_ONE && state.dstRGB == GL_ONE_MINUS_SRC_COLOR) + return BLEND_SCREEN; else if (state.srcRGB == GL_ONE && state.dstRGB == GL_ZERO) return BLEND_REPLACE; }