1 #ifndef MSP_GL_BLEND_H_
2 #define MSP_GL_BLEND_H_
4 #include <msp/datafile/objectloader.h>
5 #include <msp/strings/lexicalcast.h>
11 enum BlendEquation: std::uint8_t
20 enum BlendFactor: std::uint8_t
33 ONE_MINUS_CONSTANT_COLOR,
35 ONE_MINUS_CONSTANT_ALPHA
38 enum ColorWriteMask: std::uint8_t
49 Blends incoming fragment color values with those already in the framebuffer.
53 class Loader: public DataFile::ObjectLoader<Blend>
59 void constant(float, float, float, float);
60 void equation(BlendEquation);
61 void factors(BlendFactor, BlendFactor);
65 BlendEquation equation = ADD;
66 BlendFactor src_factor = ONE;
67 BlendFactor dst_factor = ZERO;
68 Color constant = { 0.0f, 0.0f, 0.0f, 0.0f };
69 ColorWriteMask write_mask = WRITE_ALL;
70 bool alpha_to_coverage = false;
73 Blend(BlendFactor, BlendFactor);
74 Blend(BlendEquation, BlendFactor, BlendFactor);
76 bool operator==(const Blend &) const;
77 bool operator!=(const Blend &b) const { return !operator==(b); }
80 inline bool Blend::operator==(const Blend &other) const
82 return enabled==other.enabled && equation==other.equation && src_factor==other.src_factor &&
83 dst_factor==other.dst_factor && constant==other.constant && write_mask==other.write_mask &&
84 alpha_to_coverage==other.alpha_to_coverage;
88 inline ColorWriteMask operator|(ColorWriteMask m1, ColorWriteMask m2)
89 { return static_cast<ColorWriteMask>(static_cast<int>(m1)|static_cast<int>(m2)); }
91 void operator>>(const LexicalConverter &, BlendEquation &);
92 void operator<<(LexicalConverter &, BlendEquation);
94 void operator>>(const LexicalConverter &, BlendFactor &);
95 void operator<<(LexicalConverter &, BlendFactor);
97 void operator>>(const LexicalConverter &, ColorWriteMask &);
98 void operator<<(LexicalConverter &, ColorWriteMask);
103 #include "blend_backend.h"