X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fblend.h;h=da7c8c7f266b1d08a26b95fc525a73fb1940336a;hp=ad7ba241bd1b1028e7e1bea45b5477f6b66245f6;hb=959efbf61663efd7879070ce0447e02c8a447ce0;hpb=24b24e2203c776aacd9744bb947f5cf47b03d328 diff --git a/source/core/blend.h b/source/core/blend.h index ad7ba241..da7c8c7f 100644 --- a/source/core/blend.h +++ b/source/core/blend.h @@ -35,8 +35,18 @@ enum BlendFactor ONE_MINUS_CONSTANT_ALPHA }; +enum ColorWriteMask +{ + WRITE_NONE = 0, + WRITE_RED = 1, + WRITE_GREEN = 2, + WRITE_BLUE = 4, + WRITE_ALPHA = 8, + WRITE_ALL = 15 +}; + /** -Blends incoming fragments with those already in the framebuffer. +Blends incoming fragment color values with those already in the framebuffer. */ struct Blend { @@ -51,19 +61,21 @@ struct Blend void factors(BlendFactor, BlendFactor); }; - bool enabled; - BlendEquation equation; - BlendFactor src_factor; - BlendFactor dst_factor; - Color constant; + bool enabled = false; + BlendEquation equation = ADD; + BlendFactor src_factor = ONE; + BlendFactor dst_factor = ZERO; + Color constant = { 0.0f, 0.0f, 0.0f, 0.0f }; + ColorWriteMask write_mask = WRITE_ALL; - Blend(); + Blend() = default; Blend(BlendFactor, BlendFactor); Blend(BlendEquation, BlendFactor, BlendFactor); }; -unsigned get_gl_blend_equation(BlendEquation); -unsigned get_gl_blend_factor(BlendFactor); + +inline ColorWriteMask operator|(ColorWriteMask m1, ColorWriteMask m2) +{ return static_cast(static_cast(m1)|static_cast(m2)); } void operator>>(const LexicalConverter &, BlendEquation &); void operator<<(LexicalConverter &, BlendEquation); @@ -71,7 +83,12 @@ void operator<<(LexicalConverter &, BlendEquation); void operator>>(const LexicalConverter &, BlendFactor &); void operator<<(LexicalConverter &, BlendFactor); +void operator>>(const LexicalConverter &, ColorWriteMask &); +void operator<<(LexicalConverter &, ColorWriteMask); + } // namespace GL } // namespace Msp +#include "blend_backend.h" + #endif