X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprimitivebuilder.cpp;h=92b2cb0eb0b76ef97c73875bd00f14651409c3b8;hp=e461cf211bf77f2fe79b7f25b67a579c2d99fca3;hb=0f3ae7cf6aed59f07895dfbef6740be3b666fc20;hpb=c7b4f16ba8467835d7a0100c722d653efbc00a94 diff --git a/source/primitivebuilder.cpp b/source/primitivebuilder.cpp index e461cf21..92b2cb0e 100644 --- a/source/primitivebuilder.cpp +++ b/source/primitivebuilder.cpp @@ -38,6 +38,15 @@ void PrimitiveBuilder::end() 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) @@ -47,13 +56,13 @@ PrimitiveType PrimitiveBuilder::get_type() const void PrimitiveBuilder::vertex_(float x, float y, float z, float w) { - if(!in_batch) - throw InvalidState("Vertex specification not between begin() and end()"); - 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