2 #include <msp/strings/format.h>
4 #include "stenciltest.h"
11 StencilTest::StencilTest():
14 stencil_fail_op(KEEP),
21 StencilTest::Loader::Loader(StencilTest &st):
22 ObjectLoader<StencilTest>(st)
24 add("compare", &Loader::compare);
25 add("actions", &Loader::actions);
26 add("reference", &StencilTest::reference);
29 void StencilTest::Loader::compare(Predicate c)
35 void StencilTest::Loader::actions(StencilOp sf, StencilOp df, StencilOp dp)
37 obj.stencil_fail_op = sf;
38 obj.depth_fail_op = df;
39 obj.depth_pass_op = dp;
43 unsigned get_gl_stencil_op(StencilOp op)
47 case KEEP: return GL_KEEP;
48 case SET_ZERO: return GL_ZERO;
49 case REPLACE: return GL_REPLACE;
50 case INCR: return GL_INCR;
51 case DECR: return GL_DECR;
52 case INVERT: return GL_INVERT;
53 case INCR_WRAP: return GL_INCR_WRAP;
54 case DECR_WRAP: return GL_DECR_WRAP;
55 default: throw invalid_argument("get_gl_stencil_op");
59 void operator>>(const LexicalConverter &conv, StencilOp &op)
61 const string &str = conv.get();
64 else if(str=="SET_ZERO")
66 else if(str=="REPLACE")
72 else if(str=="INVERT")
74 else if(str=="INCR_WRAP")
76 else if(str=="DECR_WRAP")
79 throw lexical_error(format("conversion of '%s' to StencilOp", str));
82 void operator<<(LexicalConverter &conv, StencilOp op)
86 case KEEP: conv.result("KEEP"); break;
87 case SET_ZERO: conv.result("SET_ZERO"); break;
88 case REPLACE: conv.result("REPLACE"); break;
89 case INCR: conv.result("INCR"); break;
90 case DECR: conv.result("DECR"); break;
91 case INVERT: conv.result("INVERT"); break;
92 case INCR_WRAP: conv.result("INCR_WRAP"); break;
93 case DECR_WRAP: conv.result("DECR_WRAP"); break;
94 default: conv.result(format("StencilOp(%#x)", static_cast<int>(op)));