]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.cpp
Rearrange vertex components
[libs/gl.git] / source / vertexarray.cpp
index 6c037f9fd030de3f382335a16dc8c8d2cc69acff..e91062bbda60b0f309f06c98effda44f6065eccd 100644 (file)
@@ -32,7 +32,7 @@ void VertexArray::reset(const VertexFormat &f)
        bool has_gen_attrs = false;
        for(const unsigned char *c=format.begin(); c!=format.end(); ++c)
        {
-               if(*c>=TEXCOORD1+4 && *c<ATTRIB1)
+               if(*c>=TEXCOORD1+4 && *c<=TEXCOORD4+12)
                        has_multitex = true;
                if(*c>=ATTRIB1)
                        has_gen_attrs = true;
@@ -140,7 +140,7 @@ void VertexArray::apply() const
                        if(!en)
                                glEnableClientState(GL_COLOR_ARRAY);
                }
-               else if(*c>=TEXCOORD1 && *c<=TEXCOORD4+28)
+               else if(*c>=TEXCOORD1 && *c<=TEXCOORD4+12)
                {
                        t -= get_component_type(TEXCOORD1);
                        if(t>0 || active_tex)
@@ -154,7 +154,8 @@ void VertexArray::apply() const
                }
                else
                {
-                       t -= get_component_type(ATTRIB1);
+                       if(t>=get_component_type(ATTRIB1))
+                               t -= get_component_type(ATTRIB1);
                        glVertexAttribPointer(t, sz, GL_FLOAT, false, bpv, base+offset);
                        if(!en)
                                glEnableVertexAttribArray(t);
@@ -172,7 +173,7 @@ void VertexArray::apply() const
                                glDisableClientState(GL_NORMAL_ARRAY);
                        else if(i==get_component_type(COLOR4_FLOAT))
                                glDisableClientState(GL_COLOR_ARRAY);
-                       else if(i>=get_component_type(TEXCOORD1) && i<=get_component_type(TEXCOORD1)+7)
+                       else if(i>=get_component_type(TEXCOORD1) && i<=get_component_type(TEXCOORD1)+3)
                        {
                                unsigned j = i-get_component_type(TEXCOORD1);
                                if(j>0 || active_tex)
@@ -180,6 +181,8 @@ void VertexArray::apply() const
                                glDisableClientState(GL_TEXTURE_COORD_ARRAY);
                                active_tex = j;
                        }
+                       else if(i<get_component_type(ATTRIB1))
+                               glDisableVertexAttribArray(i);
                        else
                                glDisableVertexAttribArray(i-get_component_type(ATTRIB1));
                }