]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarraybuilder.cpp
Add object-oriented interfaces for the various tests and blending
[libs/gl.git] / source / vertexarraybuilder.cpp
index 8e7e2cb5dd4433625747545cea073fee6715e89c..f9adcf582ac197dd951dee643f35d6bc8a2edbb5 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -25,8 +25,9 @@ void VertexArrayBuilder::vertex_(float x, float y, float z, float w)
        float *ptr=array.append();
        for(const unsigned char *c=array.get_format().begin(); c!=array.get_format().end(); ++c)
        {
-               uint size=(*c&3)+1;
-               switch(*c>>2)
+               unsigned size=(*c&3)+1;
+               unsigned type=*c>>2;
+               switch(type)
                {
                case 0:
                        *ptr++=x;
@@ -48,11 +49,11 @@ void VertexArrayBuilder::vertex_(float x, float y, float z, float w)
                case 3:
                        if(size==1)
                        {
-                               union { ubyte c[4]; float f; } u;
-                               u.c[0]=static_cast<ubyte>(cr*255);
-                               u.c[1]=static_cast<ubyte>(cg*255);
-                               u.c[2]=static_cast<ubyte>(cb*255);
-                               u.c[3]=static_cast<ubyte>(ca*255);
+                               union { unsigned char c[4]; float f; } u;
+                               u.c[0]=static_cast<unsigned char>(cr*255);
+                               u.c[1]=static_cast<unsigned char>(cg*255);
+                               u.c[2]=static_cast<unsigned char>(cb*255);
+                               u.c[3]=static_cast<unsigned char>(ca*255);
                                *ptr++=u.f;
                        }
                        else
@@ -64,7 +65,7 @@ void VertexArrayBuilder::vertex_(float x, float y, float z, float w)
                        }
                        break;
                default:
-                       const Attrib &a=av[(*c>>2)-4];
+                       const Attrib &a=av[type-4];
                        *ptr++=a.x;
                        if(size>=2) *ptr++=a.y;
                        if(size>=3) *ptr++=a.z;