]> git.tdb.fi Git - libs/gl.git/blob - source/core/stenciltest.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / core / stenciltest.h
1 #ifndef MSP_GL_STENCILTEST_H_
2 #define MSP_GL_STENCILTEST_H_
3
4 #include <msp/datafile/objectloader.h>
5 #include <msp/strings/lexicalcast.h>
6 #include "predicate.h"
7
8 namespace Msp {
9 namespace GL {
10
11 enum StencilOp: std::uint8_t
12 {
13         KEEP,
14         SET_ZERO,
15         REPLACE,
16         INCR_CLAMP,
17         DECR_CLAMP,
18         INVERT,
19         INCR_WRAP,
20         DECR_WRAP
21 };
22
23 /**
24 Tests values in the stencil buffer against a reference.  If the test fails, the
25 incoming fragment is discarded.  The stencil buffer may be modified according
26 to results of the stencil test and the depth test.
27 */
28 struct StencilTest
29 {
30         class Loader: public DataFile::ObjectLoader<StencilTest>
31         {
32         public:
33                 Loader(StencilTest &);
34
35         private:
36                 void compare(Predicate);
37                 void actions(StencilOp, StencilOp, StencilOp);
38         };
39
40         bool enabled = false;
41         Predicate compare = ALWAYS;
42         StencilOp stencil_fail_op = KEEP;
43         StencilOp depth_fail_op = KEEP;
44         StencilOp depth_pass_op = KEEP;
45         unsigned reference = 0;
46
47         bool operator==(const StencilTest &) const;
48         bool operator!=(const StencilTest &s) const { return !operator==(s); }
49 };
50
51 inline bool StencilTest::operator==(const StencilTest &other) const
52 {
53         return enabled==other.enabled && compare==other.compare && stencil_fail_op==other.stencil_fail_op &&
54                 depth_fail_op==other.depth_fail_op && depth_pass_op==other.depth_pass_op && reference==other.reference;
55 }
56
57 void operator>>(const LexicalConverter &, StencilOp &);
58 void operator<<(LexicalConverter &, StencilOp);
59
60 } // namespace GL
61 } // namespace Msp
62
63 #include "stenciltest_backend.h"
64
65 #endif