X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprimitivebuilder.cpp;h=61bde9b96f8862881deb00e0719564dae1b08549;hb=df6f8f1f26b1f230dcb1d626d278c43fd48d468d;hp=42e9d39cbb71c5bf1f56eaf53975bdd140fd607d;hpb=524515ae47ea553e8e1b9381c2027208f2d096db;p=libs%2Fgl.git diff --git a/source/primitivebuilder.cpp b/source/primitivebuilder.cpp index 42e9d39c..61bde9b9 100644 --- a/source/primitivebuilder.cpp +++ b/source/primitivebuilder.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of libmspgl -Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions +Copyright © 2008, 2010-2011 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -13,7 +13,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 +38,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