]> git.tdb.fi Git - libs/gl.git/blobdiff - source/windingtest.h
Add WindingTest and support for it in Mesh and Renderer
[libs/gl.git] / source / windingtest.h
diff --git a/source/windingtest.h b/source/windingtest.h
new file mode 100644 (file)
index 0000000..948f190
--- /dev/null
@@ -0,0 +1,51 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2011  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef WINDINGTEST_H_
+#define WINDINGTEST_H_
+
+#include <msp/strings/lexicalcast.h>
+#include "bindable.h"
+#include "gl.h"
+
+namespace Msp {
+namespace GL {
+
+enum FaceWinding
+{
+       CLOCKWISE = GL_CW,
+       COUNTERCLOCKWISE = GL_CCW
+};
+
+void operator>>(const LexicalConverter &, FaceWinding &);
+
+/**
+Tests the winding of polygons.  If the order of vertices on screen does not
+match the winding, the polygon is not rendered.
+*/
+class WindingTest: public Bindable<WindingTest>
+{
+private:
+       bool test;
+       FaceWinding winding;
+
+public:
+       WindingTest();
+       WindingTest(FaceWinding);
+
+       void bind() const;
+
+       static void unbind();
+
+       static WindingTest &clockwise();
+       static WindingTest &counterclockwise();
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif