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