X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fwindingtest.cpp;h=acbc20fc5ba127688c89c95caa0d5207a7c66f24;hb=e7556941c41b1a0fc84fe7986c98ee79eccbf564;hp=b54f71217f5b8387c054dec03eaea18380cd576c;hpb=635d00bc1a9ba43ef1224681a14d0710a098cf87;p=libs%2Fgl.git diff --git a/source/windingtest.cpp b/source/windingtest.cpp index b54f7121..acbc20fc 100644 --- a/source/windingtest.cpp +++ b/source/windingtest.cpp @@ -1,10 +1,4 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include "windingtest.h" namespace Msp { @@ -17,7 +11,7 @@ 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(): @@ -50,13 +44,23 @@ void WindingTest::unbind() glDisable(GL_CULL_FACE); } -WindingTest &WindingTest::clockwise() +const WindingTest &WindingTest::get_reverse() const +{ + if(!test) + return *this; + else 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;