Refactor vertex builders
[libs/gl.git] / source / builders / primitivebuilder.cpp
index dd869908d9240df76b2f48a2308a0396613a35ad..4b88618a0874f05519a8c22690c5ce982e003563 100644 (file)
@@ -59,12 +59,13 @@ PrimitiveType PrimitiveBuilder::get_type() const
 
 void PrimitiveBuilder::vertex_(const Vector4 &v)
 {
-       vab.color(col);
-       vab.normal(nor);
-       for(std::map<unsigned, Vector4>::iterator i=texc.begin(); i!=texc.end(); ++i)
-               vab.multitexcoord(i->first, i->second);
-       for(std::map<unsigned, Vector4>::iterator i=attr.begin(); i!=attr.end(); ++i)
-               vab.attrib(i->first, i->second);
+       const VertexFormat &format = array.get_format();
+       for(const unsigned char *c=format.begin(); c!=format.end(); ++c)
+       {
+               unsigned t = get_component_type(*c);
+               if(t<attr.size())
+                       vab.attrib(t, attr[t]);
+       }
        vab.vertex(v);
 
        if(in_batch)