]> git.tdb.fi Git - libs/gl.git/blob - source/blend.h
Use texture unit numbers instead of slot names in RenderPass
[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 BlendEquation
18 {
19         ADD              = GL_FUNC_ADD,
20         SUBTRACT         = GL_FUNC_SUBTRACT,
21         REVERSE_SUBTRACT = GL_FUNC_REVERSE_SUBTRACT,
22         MIN              = GL_MIN,
23         MAX              = GL_MAX
24 };
25
26 enum BlendFactor
27 {
28         ZERO = GL_ZERO,
29         ONE = GL_ONE,
30         SRC_COLOR = GL_SRC_COLOR,
31         ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
32         SRC_ALPHA = GL_SRC_ALPHA,
33         ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
34         DST_COLOR = GL_DST_COLOR,
35         ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
36         DST_ALPHA = GL_DST_ALPHA,
37         ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
38         CONSTANT_COLOR = GL_CONSTANT_COLOR,
39         ONE_MINUS_CONSTANT_COLOR = GL_ONE_MINUS_CONSTANT_COLOR,
40         CONSTANT_ALPHA = GL_CONSTANT_ALPHA,
41         ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA
42 };
43
44 /**
45 Blends incoming fragments with those already in the framebuffer.
46 */
47 class Blend: public Bindable<Blend>
48 {
49 private:
50         BlendEquation eq;
51         BlendFactor src_factor;
52         BlendFactor dst_factor;
53
54 public:
55         Blend();
56         Blend(BlendFactor, BlendFactor);
57         Blend(BlendEquation, BlendFactor, BlendFactor);
58
59         void bind() const;
60
61         static void unbind();
62
63         static const Blend &alpha();
64 };
65
66 } // namespace GL
67 } // namespace Msp
68
69 #endif