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 VertexArrayBuilder::~VertexArrayBuilder()
23 void VertexArrayBuilder::vertex_(float x, float y, float z, float w)
25 float *ptr = array.append();
26 for(const unsigned char *c=array.get_format().begin(); c!=array.get_format().end(); ++c)
28 unsigned sz = (*c&3)+1;
46 union { unsigned char c[4]; float f; } u;
47 u.c[0] = static_cast<unsigned char>(col.r*255);
48 u.c[1] = static_cast<unsigned char>(col.g*255);
49 u.c[2] = static_cast<unsigned char>(col.b*255);
50 u.c[3] = static_cast<unsigned char>(col.a*255);
58 if(sz>=4) *ptr++ = col.a;
62 const Vector4 &a = (t<11 ? texc[t-3] : attr[t-11]);
64 if(sz>=2) *ptr++ = a.y;
65 if(sz>=3) *ptr++ = a.z;
66 if(sz>=4) *ptr++ = a.w;