2 #include <msp/strings/format.h>
3 #include "stenciltest.h"
10 StencilTest::StencilTest():
13 stencil_fail_op(KEEP),
20 StencilTest::Loader::Loader(StencilTest &st):
21 ObjectLoader<StencilTest>(st)
23 add("compare", &Loader::compare);
24 add("actions", &Loader::actions);
25 add("reference", &StencilTest::reference);
28 void StencilTest::Loader::compare(Predicate c)
34 void StencilTest::Loader::actions(StencilOp sf, StencilOp df, StencilOp dp)
36 obj.stencil_fail_op = sf;
37 obj.depth_fail_op = df;
38 obj.depth_pass_op = dp;
42 GLenum get_gl_stencil_op(StencilOp op)
46 case KEEP: return GL_KEEP;
47 case SET_ZERO: return GL_ZERO;
48 case REPLACE: return GL_REPLACE;
49 case INCR: return GL_INCR;
50 case DECR: return GL_DECR;
51 case INVERT: return GL_INVERT;
52 case INCR_WRAP: return GL_INCR_WRAP;
53 case DECR_WRAP: return GL_DECR_WRAP;
54 default: throw invalid_argument("get_gl_stencil_op");
58 void operator>>(const LexicalConverter &conv, StencilOp &op)
60 const string &str = conv.get();
63 else if(str=="SET_ZERO")
65 else if(str=="REPLACE")
71 else if(str=="INVERT")
73 else if(str=="INCR_WRAP")
75 else if(str=="DECR_WRAP")
78 throw lexical_error(format("conversion of '%s' to StencilOp", str));
81 void operator<<(LexicalConverter &conv, StencilOp op)
85 case KEEP: conv.result("KEEP"); break;
86 case SET_ZERO: conv.result("SET_ZERO"); break;
87 case REPLACE: conv.result("REPLACE"); break;
88 case INCR: conv.result("INCR"); break;
89 case DECR: conv.result("DECR"); break;
90 case INVERT: conv.result("INVERT"); break;
91 case INCR_WRAP: conv.result("INCR_WRAP"); break;
92 case DECR_WRAP: conv.result("DECR_WRAP"); break;
93 default: conv.result(format("StencilOp(%#x)", static_cast<int>(op)));