diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 79c536b79..7f8e4dc82 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -121,6 +121,7 @@ namespace graphics { "additive", Graphics::BLEND_ADDITIVE }, { "subtractive", Graphics::BLEND_SUBTRACTIVE }, { "multiplicative", Graphics::BLEND_MULTIPLICATIVE }, + { "premultiplied", Graphics::BLEND_PREMULTIPLIED }, }; StringMap Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries)); diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 0875f24a1..0fe150d6f 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -54,6 +54,7 @@ namespace graphics BLEND_ADDITIVE, BLEND_SUBTRACTIVE, BLEND_MULTIPLICATIVE, + BLEND_PREMULTIPLIED, BLEND_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index a8935ed7a..527a487f8 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -659,6 +659,8 @@ namespace opengl glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else if (mode == BLEND_MULTIPLICATIVE) glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); + else if (mode == BLEND_PREMULTIPLIED) + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); else // mode == BLEND_ADDITIVE || mode == BLEND_SUBTRACTIVE glBlendFunc(GL_SRC_ALPHA, GL_ONE); } @@ -684,8 +686,12 @@ namespace opengl return BLEND_ADDITIVE; else if (src == GL_SRC_ALPHA && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD return BLEND_ALPHA; - else // src == GL_DST_COLOR && dst == GL_ONE_MINUS_SRC_ALPHA && equation == GL_FUNC_ADD + else if (src == GL_DST_COLOR && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD return BLEND_MULTIPLICATIVE; + else if (src == GL_ONE && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD + return BLEND_PREMULTIPLIED; + + return BLEND_MAX_ENUM; // Should never be reached. } Graphics::ColorMode Graphics::getColorMode()