+++ /dev/null
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include "vertexarray.h"
-#include "vertexarraybuilder.h"
-
-namespace Msp {
-namespace GL {
-
-VertexArrayBuilder::VertexArrayBuilder(VertexArray &a):
- array(a)
-{ }
-
-VertexArrayBuilder::~VertexArrayBuilder()
-{
- array.update_data();
-}
-
-void VertexArrayBuilder::vertex_(float x, float y, float z, float w)
-{
- float *ptr=array.append();
- for(uint fmt=array.get_format(); fmt; fmt>>=4)
- {
- uint size=(fmt&3)+1;
- switch(fmt&12)
- {
- case 0:
- *ptr++=x;
- *ptr++=y;
- if(size>=3) *ptr++=z;
- if(size>=4) *ptr++=w;
- break;
- case 4:
- *+ptr++=nx;
- *+ptr++=ny;
- *+ptr++=nz;
- break;
- case 8:
- *+ptr++=ts;
- if(size>=2) *+ptr++=tt;
- if(size>=3) *+ptr++=tr;
- if(size>=4) *+ptr++=tq;
- break;
- case 12:
- if(size==1)
- {
- union { ubyte c[4]; float f; } u;
- u.c[0]=(ubyte)(cr*255);
- u.c[1]=(ubyte)(cg*255);
- u.c[2]=(ubyte)(cb*255);
- u.c[3]=(ubyte)(ca*255);
- *+ptr++=u.f;
- }
- else
- {
- *+ptr++=cr;
- *+ptr++=cg;
- *+ptr++=cb;
- if(size>=4) *+ptr++=ca;
- }
- break;
- }
- }
-}
-
-} // namespace GL
-} // namespace Msp