X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprimitivebuilder.cpp;h=046cc5b248c12874ab889c1c09358d9946795880;hp=e032a441c00603062e750eb9367c2025c4023e1c;hb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8;hpb=b617c5d7b5283ad260a77f01e42e6170cabbc03d diff --git a/source/primitivebuilder.cpp b/source/primitivebuilder.cpp index e032a441..046cc5b2 100644 --- a/source/primitivebuilder.cpp +++ b/source/primitivebuilder.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 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 @@ -53,14 +54,15 @@ PrimitiveType PrimitiveBuilder::get_type() const return type; } -void PrimitiveBuilder::vertex_(float x, float y, float z, float w) +void PrimitiveBuilder::vertex_(const Vector4 &v) { - vab.texcoord(ts, tt, tr, tq); - vab.color(cr, cg, cb, ca); - vab.normal(nx, ny, nz); - for(std::map::iterator i=av.begin(); i!=av.end(); ++i) - vab.attrib(i->first, i->second.x, i->second.y, i->second.z, i->second.w); - vab.vertex(x, y, z, w); + vab.color(col); + vab.normal(nor); + for(std::map::iterator i=texc.begin(); i!=texc.end(); ++i) + vab.multitexcoord(i->first, i->second); + for(std::map::iterator i=attr.begin(); i!=attr.end(); ++i) + vab.attrib(i->first, i->second); + vab.vertex(v); if(in_batch) element_(array.size()-1);