]> git.tdb.fi Git - libs/gl.git/blobdiff - source/tests.h
Rework Bind and enable it to restore the old binding
[libs/gl.git] / source / tests.h
index 0fa05b46562abc36c5bce18d68ab88d732adea52..75d15036c64a12a2148abfaa0ce6f7d88f20ca1f 100644 (file)
@@ -1,16 +1,16 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2010  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
 #ifndef MSP_GL_TESTS_H_
 #define MSP_GL_TESTS_H_
 
-#include <GL/gl.h>
+#include "bindable.h"
+#include "gl.h"
 #include "predicate.h"
-#include "types.h"
 
 namespace Msp {
 namespace GL {
@@ -22,12 +22,74 @@ enum
        DEPTH_TEST   = GL_DEPTH_TEST
 };
 
-void scissor(int left, int bottom, sizei width, sizei height);
+/**
+Tests incoming fragment alpha values against a reference.  If the test fails,
+the fragment is discarded.
+*/
+class AlphaTest: public Bindable<AlphaTest>
+{
+private:
+       Predicate pred;
+       float ref;
+
+public:
+       AlphaTest();
+       AlphaTest(Predicate, float);
+
+       void bind() const;
+
+       static void unbind();
+};
 
 void alpha_func(Predicate func, float ref);
 
+
+/**
+Tests incoming fragment depth values against the depth buffer.  If the test
+fails, the fragment is discarded.
+*/
+class DepthTest: public Bindable<DepthTest>
+{
+private:
+       bool write;
+       Predicate pred;
+
+public:
+       DepthTest();
+       DepthTest(Predicate, bool = true);
+
+       void bind() const;
+
+       static const DepthTest &lequal();
+       static void unbind();
+};
+
 void depth_func(Predicate func);
 
+
+/**
+Tests fragment coordinates against a rectangle.  Any fragments outside the
+rectangle are discarded.
+*/
+class ScissorTest: public Bindable<ScissorTest>
+{
+private:
+       int left;
+       int bottom;
+       unsigned width;
+       unsigned height;
+
+public:
+       ScissorTest();
+       ScissorTest(int, int, unsigned, unsigned);
+
+       void bind() const;
+
+       static void unbind();
+};
+
+void scissor(int left, int bottom, unsigned width, unsigned height);
+
 } // namespace GL
 } // namespace Msp