From d2703e5050f86d94a3c09f2c2c3053a298b854b9 Mon Sep 17 00:00:00 2001 From: Noel Date: Sat, 28 May 2022 09:38:38 -0700 Subject: [PATCH] added NonPremultiplied BlendMode --- include/blah/graphics.h | 4 +++- src/graphics.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/blah/graphics.h b/include/blah/graphics.h index 28331b4..1cc752b 100644 --- a/include/blah/graphics.h +++ b/include/blah/graphics.h @@ -113,8 +113,10 @@ namespace Blah // BlendMode using for rendering struct BlendMode { - // Normal, pre-multiplied, Blend Mode + // Normal is Premultipled Alpha + // TODO: potentially rename normal to match that it is for Premultiplied Alpha? static const BlendMode Normal; + static const BlendMode NonPremultiplied; static const BlendMode Subtract; static const BlendMode Additive; diff --git a/src/graphics.cpp b/src/graphics.cpp index 465cf1a..c451964 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -14,6 +14,17 @@ const BlendMode BlendMode::Normal = BlendMode( 0xffffffff ); +const BlendMode BlendMode::NonPremultiplied = BlendMode( + BlendOp::Add, + BlendFactor::SrcAlpha, + BlendFactor::OneMinusSrcAlpha, + BlendOp::Add, + BlendFactor::SrcAlpha, + BlendFactor::OneMinusSrcAlpha, + BlendMask::RGBA, + 0xffffffff +); + const BlendMode BlendMode::Subtract = BlendMode( BlendOp::ReverseSubtract, BlendFactor::One,