1 #include "vertexarray.h"
2 #include "vertexarraybuilder.h"
7 VertexArrayBuilder::VertexArrayBuilder(VertexArray &a):
11 void VertexArrayBuilder::vertex_(const Vector4 &vtx)
13 float *ptr = array.append();
14 const VertexFormat &format = array.get_format();
15 for(const unsigned char *c=format.begin(); c!=format.end(); ++c)
17 unsigned sz = get_component_size(*c);
18 unsigned t = get_component_type(*c);
21 else if(*c==COLOR4_UBYTE)
23 union { unsigned char c[4]; float f; } u;
24 u.c[0] = static_cast<unsigned char>(attr[t].x*255);
25 u.c[1] = static_cast<unsigned char>(attr[t].y*255);
26 u.c[2] = static_cast<unsigned char>(attr[t].z*255);
27 u.c[3] = static_cast<unsigned char>(attr[t].w*255);
32 const Vector4 &v = (t==0 ? vtx : attr[t]);
34 if(sz>=2) *ptr++ = v.y;
35 if(sz>=3) *ptr++ = v.z;
36 if(sz>=4) *ptr++ = v.w;