]> git.tdb.fi Git - libs/gl.git/blob - source/core/blend.h
Wrap Limits into a DeviceInfo struct
[libs/gl.git] / source / core / blend.h
1 #ifndef MSP_GL_BLEND_H_
2 #define MSP_GL_BLEND_H_
3
4 #include <msp/datafile/objectloader.h>
5 #include <msp/strings/lexicalcast.h>
6 #include "color.h"
7
8 namespace Msp {
9 namespace GL {
10
11 enum BlendEquation
12 {
13         ADD,
14         SUBTRACT,
15         REVERSE_SUBTRACT,
16         MIN,
17         MAX
18 };
19
20 enum BlendFactor
21 {
22         ZERO,
23         ONE,
24         SRC_COLOR,
25         ONE_MINUS_SRC_COLOR,
26         SRC_ALPHA,
27         ONE_MINUS_SRC_ALPHA,
28         DST_COLOR,
29         ONE_MINUS_DST_COLOR,
30         DST_ALPHA,
31         ONE_MINUS_DST_ALPHA,
32         CONSTANT_COLOR,
33         ONE_MINUS_CONSTANT_COLOR,
34         CONSTANT_ALPHA,
35         ONE_MINUS_CONSTANT_ALPHA
36 };
37
38 /**
39 Blends incoming fragments with those already in the framebuffer.
40 */
41 struct Blend
42 {
43         class Loader: public DataFile::ObjectLoader<Blend>
44         {
45         public:
46                 Loader(Blend &);
47
48         private:
49                 void constant(float, float, float, float);
50                 void equation(BlendEquation);
51                 void factors(BlendFactor, BlendFactor);
52         };
53
54         bool enabled;
55         BlendEquation equation;
56         BlendFactor src_factor;
57         BlendFactor dst_factor;
58         Color constant;
59
60         Blend();
61         Blend(BlendFactor, BlendFactor);
62         Blend(BlendEquation, BlendFactor, BlendFactor);
63 };
64
65 unsigned get_gl_blend_equation(BlendEquation);
66 unsigned get_gl_blend_factor(BlendFactor);
67
68 void operator>>(const LexicalConverter &, BlendEquation &);
69 void operator<<(LexicalConverter &, BlendEquation);
70
71 void operator>>(const LexicalConverter &, BlendFactor &);
72 void operator<<(LexicalConverter &, BlendFactor);
73
74 } // namespace GL
75 } // namespace Msp
76
77 #endif