]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/stenciltest.h
Redesign depth and stencil test and blend state management
[libs/gl.git] / source / core / stenciltest.h
diff --git a/source/core/stenciltest.h b/source/core/stenciltest.h
new file mode 100644 (file)
index 0000000..cdc6138
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef MSP_GL_STENCILTEST_H_
+#define MSP_GL_STENCILTEST_H_
+
+#include <msp/datafile/objectloader.h>
+#include <msp/strings/lexicalcast.h>
+#include "predicate.h"
+
+namespace Msp {
+namespace GL {
+
+enum StencilOp
+{
+       KEEP,
+       SET_ZERO,
+       REPLACE,
+       INCR,
+       DECR,
+       INVERT,
+       INCR_WRAP,
+       DECR_WRAP
+};
+
+/**
+Tests values in the stencil buffer against a reference.  If the test fails, the
+incoming fragment is discarded.  The stencil buffer may be modified according
+to results of the stencil test and the depth test.
+*/
+struct StencilTest
+{
+       class Loader: public DataFile::ObjectLoader<StencilTest>
+       {
+       public:
+               Loader(StencilTest &);
+
+       private:
+               void compare(Predicate);
+               void actions(StencilOp, StencilOp, StencilOp);
+       };
+
+       bool enabled;
+       Predicate compare;
+       StencilOp stencil_fail_op;
+       StencilOp depth_fail_op;
+       StencilOp depth_pass_op;
+       unsigned reference;
+
+       StencilTest();
+};
+
+GLenum get_gl_stencil_op(StencilOp);
+
+void operator>>(const LexicalConverter &, StencilOp &);
+void operator<<(LexicalConverter &, StencilOp);
+
+} // namespace GL
+} // namespace Msp
+
+#endif