1 #include "vertexarray.h"
2 #include "vertexarraybuilder.h"
7 VertexArrayBuilder::VertexArrayBuilder(VertexArray &a):
11 void VertexArrayBuilder::vertex_(const Vector4 &ver)
13 float *ptr = array.append();
14 for(const unsigned char *c=array.get_format().begin(); c!=array.get_format().end(); ++c)
16 unsigned sz = get_component_size(*c);
17 unsigned t = get_component_type(*c);
20 union { unsigned char c[4]; float f; } u;
21 u.c[0] = static_cast<unsigned char>(col.r*255);
22 u.c[1] = static_cast<unsigned char>(col.g*255);
23 u.c[2] = static_cast<unsigned char>(col.b*255);
24 u.c[3] = static_cast<unsigned char>(col.a*255);
33 else if(t==get_component_type(COLOR4_FLOAT))
38 if(sz>=4) *ptr++ = col.a;
43 if(t==get_component_type(VERTEX3))
45 else if(*c>=TEXCOORD1 && *c<=TEXCOORD4+12)
46 v = &texc[t-get_component_type(TEXCOORD1)];
48 v = &attr[t-get_component_type(ATTRIB1)];
52 if(sz>=2) *ptr++ = v->y;
53 if(sz>=3) *ptr++ = v->z;
54 if(sz>=4) *ptr++ = v->w;