And the code....
#define USE_GL_CVA 1
/* numvert_v == number of vertices*/
/* numtri_v == number of triangles*/
void SV_Simple::draw(int fill)const
{
EC();
if (!fill)
glPolygonMode(GL_FRONT,GL_LINE);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(Vert_t), &vertdata_v[0].mvx);
glNormalPointer(GL_FLOAT, sizeof(Vert_t), &vertdata_v[0].mnx);
#if USE_GL_CVA
glLockArraysEXT(0,numvert_v);
#endif
int old_col=-1;
for(int i=0;i<numtri_v;i++){
assert(colordata_v[i] != old_col);
assert(colordata_v[i]);
old_col=colordata_v[i];
unsigned tmp=old_col;
GLfloat tmp_color[4];
tmp_color[3]=1;
tmp_color[2]=(tmp & 255)/255.0;
tmp >>= 8;
tmp_color[1]=(tmp & 255)/255.0;
tmp >>= 8;
tmp_color[0]=(tmp & 255)/255.0;
glMaterialfv(GL_FRONT, GL_AMBIENT, tmp_color);
glMaterialfv(GL_FRONT, GL_DIFFUSE, tmp_color);
for(int j=i+1;j<numtri_v;j++)
if (colordata_v[j] != old_col)
break;
glDrawElements(GL_TRIANGLES,(j-i)*3,
GL_UNSIGNED_INT,
tridata_v+i*3);
i=j-1;
}
#if USE_GL_CVA
glUnlockArraysEXT();
#endif
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
if (!fill)
glPolygonMode(GL_FRONT,GL_FILL);
EC();
}
_______________________________________________
Mesa-dev maillist - [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-dev