]> git.tdb.fi Git - libs/gl.git/blobdiff - source/primitivetype.cpp
Add Mesh and Batch classes
[libs/gl.git] / source / primitivetype.cpp
diff --git a/source/primitivetype.cpp b/source/primitivetype.cpp
new file mode 100644 (file)
index 0000000..c11a59f
--- /dev/null
@@ -0,0 +1,45 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "primitivetype.h"
+
+namespace Msp {
+namespace GL {
+
+std::istream &operator>>(std::istream &in, PrimitiveType &pt)
+{
+       std::string str;
+       in>>str;
+
+       if(str=="POINTS")
+               pt=POINTS;
+       else if(str=="LINES")
+               pt=LINES;
+       else if(str=="LINE_LOOP")
+               pt=LINE_LOOP;
+       else if(str=="LINE_STRIP")
+               pt=LINE_STRIP;
+       else if(str=="TRIANGLES")
+               pt=TRIANGLES;
+       else if(str=="TRIANGLE_STRIP")
+               pt=TRIANGLE_STRIP;
+       else if(str=="TRIANGLE_FAN")
+               pt=TRIANGLE_FAN;
+       else if(str=="QUADS")
+               pt=QUADS;
+       else if(str=="QUAD_STRIP")
+               pt=QUAD_STRIP;
+       else if(str=="POLYGON")
+               pt=POLYGON;
+       else
+               in.setstate(std::ios_base::failbit);
+
+       return in;
+}
+
+} // namespace GL
+} // namespace Msp