]> git.tdb.fi Git - libs/gl.git/blob - source/tests.h
02e5f929475130236e5c43f48de96f2c0ff3cfee
[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 /**
19 Tests incoming fragment alpha values against a reference.  If the test fails,
20 the fragment is discarded.
21 */
22 class AlphaTest: public Bindable<AlphaTest>
23 {
24 private:
25         Predicate pred;
26         float ref;
27
28 public:
29         AlphaTest();
30         AlphaTest(Predicate, float);
31
32         void bind() const;
33
34         static void unbind();
35 };
36
37
38 /**
39 Tests incoming fragment depth values against the depth buffer.  If the test
40 fails, the fragment is discarded.
41 */
42 class DepthTest: public Bindable<DepthTest>
43 {
44 private:
45         bool write;
46         Predicate pred;
47
48 public:
49         DepthTest();
50         DepthTest(Predicate, bool = true);
51
52         void bind() const;
53
54         static const DepthTest &lequal();
55         static void unbind();
56 };
57
58
59 /**
60 Tests fragment coordinates against a rectangle.  Any fragments outside the
61 rectangle are discarded.
62 */
63 class ScissorTest: public Bindable<ScissorTest>
64 {
65 private:
66         int left;
67         int bottom;
68         unsigned width;
69         unsigned height;
70
71 public:
72         ScissorTest();
73         ScissorTest(int, int, unsigned, unsigned);
74
75         void bind() const;
76
77         static void unbind();
78 };
79
80 } // namespace GL
81 } // namespace Msp
82
83 #endif