PrimitiveBuilder::PrimitiveBuilder(VertexArray &a):
array(a),
+ vab(array),
in_batch(false)
{ }
type=t;
in_batch=true;
- builder=array.modify();
begin_();
}
if(!in_batch)
throw InvalidState("end() called without begin()");
- builder=0;
in_batch=false;
end_();
}
+void PrimitiveBuilder::element(unsigned i)
+{
+ if(!in_batch)
+ throw InvalidState("Element specification not between begin() and end()");
+ if(i>=array.size())
+ throw InvalidParameterValue("Element index out of range");
+ element_(i);
+}
+
PrimitiveType PrimitiveBuilder::get_type() const
{
if(!in_batch)
void PrimitiveBuilder::vertex_(float x, float y, float z, float w)
{
- if(!in_batch)
- throw InvalidState("Vertex specification not between begin() and end()");
+ vab.texcoord(ts, tt, tr, tq);
+ vab.color(cr, cg, cb, ca);
+ vab.normal(nx, ny, nz);
+ for(std::map<unsigned, Attrib>::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);
- builder->texcoord(ts, tt, tr,tq);
- builder->color(cr, cg, cb, ca);
- builder->normal(nx, ny, nz);
- builder->vertex(x, y, z, w);
+ if(in_batch)
+ element_(array.size()-1);
}
} // namespace GL