]> git.tdb.fi Git - libs/gl.git/blob - source/core/tests.cpp
Add a visitor to dump the AST for debugging purposes
[libs/gl.git] / source / core / tests.cpp
1 #include "tests.h"
2
3 namespace Msp {
4 namespace GL {
5
6 DepthTest::DepthTest():
7         write(true),
8         pred(LESS)
9 { }
10
11 DepthTest::DepthTest(Predicate p, bool w):
12         write(w),
13         pred(p)
14 { }
15
16 void DepthTest::bind() const
17 {
18         if(set_current(this))
19         {
20                 glEnable(GL_DEPTH_TEST);
21                 glDepthFunc(pred);
22                 glDepthMask(write);
23         }
24 }
25
26 const DepthTest &DepthTest::lequal()
27 {
28         static DepthTest test(LEQUAL);
29         return test;
30 }
31
32 void DepthTest::unbind()
33 {
34         if(set_current(0))
35         {
36                 glDisable(GL_DEPTH_TEST);
37                 // Allow glClear(GL_DEPTH_BUFFER_BIT) to work
38                 glDepthMask(true);
39         }
40 }
41
42
43 ScissorTest::ScissorTest():
44         left(0),
45         bottom(0),
46         width(1),
47         height(1)
48 { }
49
50 ScissorTest::ScissorTest(int l, int b, unsigned w, unsigned h):
51         left(l),
52         bottom(b),
53         width(w),
54         height(h)
55 { }
56
57 void ScissorTest::bind() const
58 {
59         if(set_current(this))
60         {
61                 glEnable(GL_SCISSOR_TEST);
62                 glScissor(left, bottom, width, height);
63         }
64 }
65
66 void ScissorTest::unbind()
67 {
68         if(set_current(0))
69                 glDisable(GL_SCISSOR_TEST);
70 }
71
72 } // namespace GL
73 } // namespace Msp