]> git.tdb.fi Git - libs/gl.git/blob - source/tests.h
Rework Bind and enable it to restore the old binding
[libs/gl.git] / source / tests.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007, 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_TESTS_H_
9 #define MSP_GL_TESTS_H_
10
11 #include "bindable.h"
12 #include "gl.h"
13 #include "predicate.h"
14
15 namespace Msp {
16 namespace GL {
17
18 enum
19 {
20         SCISSOR_TEST = GL_SCISSOR_TEST,
21         ALPHA_TEST   = GL_ALPHA_TEST,
22         DEPTH_TEST   = GL_DEPTH_TEST
23 };
24
25 /**
26 Tests incoming fragment alpha values against a reference.  If the test fails,
27 the fragment is discarded.
28 */
29 class AlphaTest: public Bindable<AlphaTest>
30 {
31 private:
32         Predicate pred;
33         float ref;
34
35 public:
36         AlphaTest();
37         AlphaTest(Predicate, float);
38
39         void bind() const;
40
41         static void unbind();
42 };
43
44 void alpha_func(Predicate func, float ref);
45
46
47 /**
48 Tests incoming fragment depth values against the depth buffer.  If the test
49 fails, the fragment is discarded.
50 */
51 class DepthTest: public Bindable<DepthTest>
52 {
53 private:
54         bool write;
55         Predicate pred;
56
57 public:
58         DepthTest();
59         DepthTest(Predicate, bool = true);
60
61         void bind() const;
62
63         static const DepthTest &lequal();
64         static void unbind();
65 };
66
67 void depth_func(Predicate func);
68
69
70 /**
71 Tests fragment coordinates against a rectangle.  Any fragments outside the
72 rectangle are discarded.
73 */
74 class ScissorTest: public Bindable<ScissorTest>
75 {
76 private:
77         int left;
78         int bottom;
79         unsigned width;
80         unsigned height;
81
82 public:
83         ScissorTest();
84         ScissorTest(int, int, unsigned, unsigned);
85
86         void bind() const;
87
88         static void unbind();
89 };
90
91 void scissor(int left, int bottom, unsigned width, unsigned height);
92
93 } // namespace GL
94 } // namespace Msp
95
96 #endif