]> git.tdb.fi Git - libs/gl.git/blob - source/core/blend.h
Add generator ID for the SPIR-V compiler
[libs/gl.git] / source / core / blend.h
1 #ifndef MSP_GL_BLEND_H_
2 #define MSP_GL_BLEND_H_
3
4 #include <msp/strings/lexicalcast.h>
5 #include "bindable.h"
6 #include "gl.h"
7 #include <msp/gl/extensions/ext_blend_minmax.h>
8
9 namespace Msp {
10 namespace GL {
11
12 enum BlendEquation
13 {
14         ADD              = GL_FUNC_ADD,
15         SUBTRACT         = GL_FUNC_SUBTRACT,
16         REVERSE_SUBTRACT = GL_FUNC_REVERSE_SUBTRACT,
17         MIN              = GL_MIN,
18         MAX              = GL_MAX
19 };
20
21 enum BlendFactor
22 {
23         ZERO = GL_ZERO,
24         ONE = GL_ONE,
25         SRC_COLOR = GL_SRC_COLOR,
26         ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
27         SRC_ALPHA = GL_SRC_ALPHA,
28         ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
29         DST_COLOR = GL_DST_COLOR,
30         ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
31         DST_ALPHA = GL_DST_ALPHA,
32         ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
33         CONSTANT_COLOR = GL_CONSTANT_COLOR,
34         ONE_MINUS_CONSTANT_COLOR = GL_ONE_MINUS_CONSTANT_COLOR,
35         CONSTANT_ALPHA = GL_CONSTANT_ALPHA,
36         ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA
37 };
38
39 /**
40 Blends incoming fragments with those already in the framebuffer.
41 */
42 class Blend: public Bindable<Blend>
43 {
44 private:
45         BlendEquation eq;
46         BlendFactor src_factor;
47         BlendFactor dst_factor;
48
49 public:
50         Blend();
51         Blend(BlendFactor, BlendFactor);
52         Blend(BlendEquation, BlendFactor, BlendFactor);
53
54         void bind() const;
55
56         static void unbind();
57
58         static const Blend &alpha();
59         static const Blend &additive();
60         static const Blend &additive_alpha();
61 };
62
63 void operator>>(const LexicalConverter &, BlendFactor &);
64 void operator<<(LexicalConverter &, BlendFactor);
65
66 } // namespace GL
67 } // namespace Msp
68
69 #endif