+#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