]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/blend.h
Make various enums use uint8_t as their underlying type
[libs/gl.git] / source / core / blend.h
index a1180050163b31dbd009acd1987d27c8507fb5b3..50ea13bd28a897bd6bc3fa491baffaeb66cb8ab4 100644 (file)
@@ -8,7 +8,7 @@
 namespace Msp {
 namespace GL {
 
-enum BlendEquation
+enum BlendEquation: std::uint8_t
 {
        ADD,
        SUBTRACT,
@@ -17,7 +17,7 @@ enum BlendEquation
        MAX
 };
 
-enum BlendFactor
+enum BlendFactor: std::uint8_t
 {
        ZERO,
        ONE,
@@ -35,7 +35,7 @@ enum BlendFactor
        ONE_MINUS_CONSTANT_ALPHA
 };
 
-enum ColorWriteMask
+enum ColorWriteMask: std::uint8_t
 {
        WRITE_NONE = 0,
        WRITE_RED = 1,
@@ -46,7 +46,7 @@ enum ColorWriteMask
 };
 
 /**
-Blends incoming fragments with those already in the framebuffer.
+Blends incoming fragment color values with those already in the framebuffer.
 */
 struct Blend
 {
@@ -61,14 +61,14 @@ struct Blend
                void factors(BlendFactor, BlendFactor);
        };
 
-       bool enabled;
-       BlendEquation equation;
-       BlendFactor src_factor;
-       BlendFactor dst_factor;
-       Color constant;
-       ColorWriteMask write_mask;
+       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);
 };
@@ -77,9 +77,6 @@ struct Blend
 inline ColorWriteMask operator|(ColorWriteMask m1, ColorWriteMask m2)
 { return static_cast<ColorWriteMask>(static_cast<int>(m1)|static_cast<int>(m2)); }
 
-unsigned get_gl_blend_equation(BlendEquation);
-unsigned get_gl_blend_factor(BlendFactor);
-
 void operator>>(const LexicalConverter &, BlendEquation &);
 void operator<<(LexicalConverter &, BlendEquation);
 
@@ -92,4 +89,6 @@ void operator<<(LexicalConverter &, ColorWriteMask);
 } // namespace GL
 } // namespace Msp
 
+#include "blend_backend.h"
+
 #endif