]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexformat.cpp
Use a struct to store texture slots in Technique
[libs/gl.git] / source / vertexformat.cpp
index 232690ede2f99f2c7d1ebb8411d9ad442c68dffa..b9bd7b9402414f16ad3b0c70d11a835b12ef9c3f 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -10,6 +10,8 @@ Distributed under the LGPL
 #include "except.h"
 #include "vertexformat.h"
 
+using namespace std;
+
 namespace Msp {
 namespace GL {
 
@@ -87,9 +89,9 @@ VertexFormat operator,(const VertexFormat &f, unsigned i)
        if(*c<ATTRIB1)
                throw InvalidState("Last component is not a generic attribute");
        // VertexArray uses an unsigned to store flags for enabled arrays
-       if(i<1 || i>28)
+       if(i>=28)
                throw InvalidParameterValue("Generic attribute index out of range");
-       *c+=(i-1)*4;
+       *c+=i*4;
 
        return r;
 }
@@ -102,16 +104,16 @@ uint get_stride(const VertexFormat &f)
        return stride;
 }
 
-std::istream &operator>>(std::istream &in, VertexFormat &f)
+istream &operator>>(istream &in, VertexFormat &f)
 {
-       std::string str;
+       string str;
        in>>str;
 
        unsigned start=0;
 
        while(1)
        {
-               unsigned underscore=str.find('_', start);
+               string::size_type underscore=str.find('_', start);
                bool fail=false;
                if(!str.compare(start, underscore-start, "VERTEX2"))
                        f=(f,VERTEX2);
@@ -162,11 +164,11 @@ std::istream &operator>>(std::istream &in, VertexFormat &f)
 
                if(fail)
                {
-                       in.setstate(std::ios_base::failbit);
+                       in.setstate(ios_base::failbit);
                        break;
                }
 
-               if(underscore==std::string::npos)
+               if(underscore==string::npos)
                        break;
                start=underscore+1;
        }