]> git.tdb.fi Git - libs/gl.git/blob - source/blend.h
Add object-oriented interfaces for the various tests and blending
[libs/gl.git] / source / blend.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2008, 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_BLEND_H_
9 #define MSP_GL_BLEND_H_
10
11 #include "bindable.h"
12 #include "gl.h"
13
14 namespace Msp {
15 namespace GL {
16
17 enum
18 {
19         BLEND = GL_BLEND
20 };
21
22 enum BlendEquation
23 {
24         ADD              = GL_FUNC_ADD,
25         SUBTRACT         = GL_FUNC_SUBTRACT,
26         REVERSE_SUBTRACT = GL_FUNC_REVERSE_SUBTRACT,
27         MIN              = GL_MIN,
28         MAX              = GL_MAX
29 };
30
31 enum BlendFactor
32 {
33         ZERO = GL_ZERO,
34         ONE = GL_ONE,
35         SRC_COLOR = GL_SRC_COLOR,
36         ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
37         SRC_ALPHA = GL_SRC_ALPHA,
38         ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
39         DST_COLOR = GL_DST_COLOR,
40         ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
41         DST_ALPHA = GL_DST_ALPHA,
42         ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
43         CONSTANT_COLOR = GL_CONSTANT_COLOR,
44         ONE_MINUS_CONSTANT_COLOR = GL_ONE_MINUS_CONSTANT_COLOR,
45         CONSTANT_ALPHA = GL_CONSTANT_ALPHA,
46         ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA
47 };
48
49 /**
50 Blends incoming fragments with those already in the framebuffer.
51 */
52 class Blend: public Bindable<Blend>
53 {
54 private:
55         BlendEquation eq;
56         BlendFactor src_factor;
57         BlendFactor dst_factor;
58
59 public:
60         Blend();
61         Blend(BlendFactor, BlendFactor);
62         Blend(BlendEquation, BlendFactor, BlendFactor);
63
64         void bind() const;
65
66         static const Blend &alpha();
67         static void unbind();
68 };
69
70 void blend_equation(BlendEquation eq);
71 void blend_func(BlendFactor src, BlendFactor dst);
72
73 } // namespace GL
74 } // namespace Msp
75
76 #endif