]> git.tdb.fi Git - libs/gl.git/blobdiff - source/windingtest.cpp
Add a speed parameter for animation playback
[libs/gl.git] / source / windingtest.cpp
index b54f71217f5b8387c054dec03eaea18380cd576c..0b8218adbf2773971b589c89cccefa134d403788 100644 (file)
@@ -1,10 +1,4 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2011  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
+#include <msp/strings/format.h>
 #include "windingtest.h"
 
 namespace Msp {
@@ -17,16 +11,14 @@ void operator>>(const LexicalConverter &conv, FaceWinding &winding)
        else if(conv.get()=="COUNTERCLOCKWISE")
                winding = COUNTERCLOCKWISE;
        else
-               throw InvalidParameterValue("Invalid FaceWinding");
+               throw lexical_error(format("conversion of '%s' to FaceWinding", conv.get()));
 }
 
 WindingTest::WindingTest():
-       test(false),
        winding(COUNTERCLOCKWISE)
 { }
 
 WindingTest::WindingTest(FaceWinding w):
-       test(true),
        winding(w)
 { }
 
@@ -34,13 +26,8 @@ void WindingTest::bind() const
 {
        if(set_current(this))
        {
-               if(test)
-               {
-                       glEnable(GL_CULL_FACE);
-                       glFrontFace(winding);
-               }
-               else
-                       glDisable(GL_CULL_FACE);
+               glEnable(GL_CULL_FACE);
+               glFrontFace(winding);
        }
 }
 
@@ -50,13 +37,21 @@ void WindingTest::unbind()
                glDisable(GL_CULL_FACE);
 }
 
-WindingTest &WindingTest::clockwise()
+const WindingTest &WindingTest::get_reverse() const
+{
+       if(winding==CLOCKWISE)
+               return counterclockwise();
+       else
+               return clockwise();
+}
+
+const WindingTest &WindingTest::clockwise()
 {
        static WindingTest test(CLOCKWISE);
        return test;
 }
 
-WindingTest &WindingTest::counterclockwise()
+const WindingTest &WindingTest::counterclockwise()
 {
        static WindingTest test(COUNTERCLOCKWISE);
        return test;