]> git.tdb.fi Git - libs/gl.git/blobdiff - source/primitivebuilder.cpp
Drop Id tags and copyright notices from files
[libs/gl.git] / source / primitivebuilder.cpp
index 42e9d39cbb71c5bf1f56eaf53975bdd140fd607d..046cc5b248c12874ab889c1c09358d9946795880 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2008, 2010  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "primitivebuilder.h"
 
 namespace Msp {
@@ -13,7 +6,8 @@ namespace GL {
 PrimitiveBuilder::PrimitiveBuilder(VertexArray &a):
        array(a),
        vab(array),
-       in_batch(false)
+       in_batch(false),
+       offs(0)
 { }
 
 void PrimitiveBuilder::begin(PrimitiveType t)
@@ -37,13 +31,20 @@ void PrimitiveBuilder::end()
        end_();
 }
 
+void PrimitiveBuilder::offset(unsigned o)
+{
+       if(o>array.size())
+               throw InvalidParameterValue("Element offset out of range");
+       offs = o;
+}
+
 void PrimitiveBuilder::element(unsigned i)
 {
        if(!in_batch)
                throw InvalidState("Element specification not between begin() and end()");
-       if(i>=array.size())
+       if(offs+i>=array.size())
                throw InvalidParameterValue("Element index out of range");
-       element_(i);
+       element_(offs+i);
 }
 
 PrimitiveType PrimitiveBuilder::get_type() const