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 *a=format.begin(); a!=format.end(); ++a)
17 unsigned sem = get_attribute_semantic(*a);
18 unsigned sz = get_attribute_size(*a);
21 else if(*a==COLOR4_UBYTE)
23 union { unsigned char c[4]; float f; } u;
24 u.c[0] = static_cast<unsigned char>(attr[sem].x*255);
25 u.c[1] = static_cast<unsigned char>(attr[sem].y*255);
26 u.c[2] = static_cast<unsigned char>(attr[sem].z*255);
27 u.c[3] = static_cast<unsigned char>(attr[sem].w*255);
32 const Vector4 &v = (sem==0 ? vtx : attr[sem]);
34 if(sz>=2) *ptr++ = v.y;
35 if(sz>=3) *ptr++ = v.z;
36 if(sz>=4) *ptr++ = v.w;