]> git.tdb.fi Git - libs/gl.git/blobdiff - source/tests.cpp
Add more public methods to Transform
[libs/gl.git] / source / tests.cpp
index a74400636c4b847d44bf3ca40bce53cc41f587d0..8e24bb52facc436a0a75451a57726737a574bb22 100644 (file)
@@ -1,28 +1,72 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "tests.h"
 
 namespace Msp {
 namespace GL {
 
-void scissor(int left, int bottom, sizei width, sizei height)
+DepthTest::DepthTest():
+       write(true),
+       pred(LESS)
+{ }
+
+DepthTest::DepthTest(Predicate p, bool w):
+       write(w),
+       pred(p)
+{ }
+
+void DepthTest::bind() const
+{
+       if(set_current(this))
+       {
+               glEnable(GL_DEPTH_TEST);
+               glDepthFunc(pred);
+               glDepthMask(write);
+       }
+}
+
+const DepthTest &DepthTest::lequal()
 {
-       glScissor(left, bottom, width, height);
+       static DepthTest test(LEQUAL);
+       return test;
 }
 
-void alpha_func(Predicate func, float ref)
+void DepthTest::unbind()
+{
+       if(set_current(0))
+       {
+               glDisable(GL_DEPTH_TEST);
+               // Allow glClear(GL_DEPTH_BUFFER_BIT) to work
+               glDepthMask(true);
+       }
+}
+
+
+ScissorTest::ScissorTest():
+       left(0),
+       bottom(0),
+       width(1),
+       height(1)
+{ }
+
+ScissorTest::ScissorTest(int l, int b, unsigned w, unsigned h):
+       left(l),
+       bottom(b),
+       width(w),
+       height(h)
+{ }
+
+void ScissorTest::bind() const
 {
-       glAlphaFunc(func, ref);
+       if(set_current(this))
+       {
+               glEnable(GL_SCISSOR_TEST);
+               glScissor(left, bottom, width, height);
+       }
 }
 
-void depth_func(Predicate func)
+void ScissorTest::unbind()
 {
-       glDepthFunc(func);
+       if(set_current(0))
+               glDisable(GL_SCISSOR_TEST);
 }
 
 } // namespace GL