]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/cullface.cpp
Refactor winding-based culling
[libs/gl.git] / source / core / cullface.cpp
diff --git a/source/core/cullface.cpp b/source/core/cullface.cpp
new file mode 100644 (file)
index 0000000..b183950
--- /dev/null
@@ -0,0 +1,32 @@
+#include <msp/strings/format.h>
+#include "cullface.h"
+
+namespace Msp {
+namespace GL {
+
+void operator>>(const LexicalConverter &conv, FaceWinding &winding)
+{
+       if(conv.get()=="NON_MANIFOLD")
+               winding = NON_MANIFOLD;
+       else if(conv.get()=="CLOCKWISE")
+               winding = CLOCKWISE;
+       else if(conv.get()=="COUNTERCLOCKWISE")
+               winding = COUNTERCLOCKWISE;
+       else
+               throw lexical_error(format("conversion of '%s' to FaceWinding", conv.get()));
+}
+
+void operator>>(const LexicalConverter &conv, CullMode &cull)
+{
+       if(conv.get()=="NO_CULL")
+               cull = NO_CULL;
+       else if(conv.get()=="CULL_FRONT")
+               cull = CULL_FRONT;
+       else if(conv.get()=="CULL_BACK")
+               cull = CULL_BACK;
+       else
+               throw lexical_error(format("conversion of '%s' to CullMode", conv.get()));
+}
+
+} // namespace GL
+} // namespace Msp