X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprimitivebuilder.cpp;h=046cc5b248c12874ab889c1c09358d9946795880;hp=42e9d39cbb71c5bf1f56eaf53975bdd140fd607d;hb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8;hpb=524515ae47ea553e8e1b9381c2027208f2d096db diff --git a/source/primitivebuilder.cpp b/source/primitivebuilder.cpp index 42e9d39c..046cc5b2 100644 --- a/source/primitivebuilder.cpp +++ b/source/primitivebuilder.cpp @@ -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