3 This file is part of libmspgl
4 Copyright © 2007-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include "vertexarray.h"
9 #include "vertexarraybuilder.h"
14 VertexArrayBuilder::VertexArrayBuilder(VertexArray &a):
18 void VertexArrayBuilder::vertex_(const Vector4 &v)
20 float *ptr = array.append();
21 for(const unsigned char *c=array.get_format().begin(); c!=array.get_format().end(); ++c)
23 unsigned sz = (*c&3)+1;
30 if(sz>=3) *ptr++ = v.z;
31 if(sz>=4) *ptr++ = v.w;
41 union { unsigned char c[4]; float f; } u;
42 u.c[0] = static_cast<unsigned char>(col.r*255);
43 u.c[1] = static_cast<unsigned char>(col.g*255);
44 u.c[2] = static_cast<unsigned char>(col.b*255);
45 u.c[3] = static_cast<unsigned char>(col.a*255);
53 if(sz>=4) *ptr++ = col.a;
57 const Vector4 &a = (t<11 ? texc[t-3] : attr[t-11]);
59 if(sz>=2) *ptr++ = a.y;
60 if(sz>=3) *ptr++ = a.z;
61 if(sz>=4) *ptr++ = a.w;