X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprimitivebuilder.cpp;h=42e9d39cbb71c5bf1f56eaf53975bdd140fd607d;hb=5172d32d67595ea0b70184fadcfcb8e023cccbc8;hp=92b2cb0eb0b76ef97c73875bd00f14651409c3b8;hpb=0f3ae7cf6aed59f07895dfbef6740be3b666fc20;p=libs%2Fgl.git diff --git a/source/primitivebuilder.cpp b/source/primitivebuilder.cpp index 92b2cb0e..42e9d39c 100644 --- a/source/primitivebuilder.cpp +++ b/source/primitivebuilder.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -12,6 +12,7 @@ namespace GL { PrimitiveBuilder::PrimitiveBuilder(VertexArray &a): array(a), + vab(array), in_batch(false) { } @@ -20,9 +21,8 @@ void PrimitiveBuilder::begin(PrimitiveType t) if(in_batch) throw InvalidState("begin() already called"); - type=t; - in_batch=true; - builder=array.modify(); + type = t; + in_batch = true; begin_(); } @@ -32,8 +32,7 @@ void PrimitiveBuilder::end() if(!in_batch) throw InvalidState("end() called without begin()"); - builder=0; - in_batch=false; + in_batch = false; end_(); } @@ -54,12 +53,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) { - builder->texcoord(ts, tt, tr,tq); - builder->color(cr, cg, cb, ca); - builder->normal(nx, ny, nz); - builder->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);