void Render::drawPolygonFlat(const Vertex *vertices, int verticesCount, int color) {
switch (color) {
case kFlatColorRed:
glColor4f(1., 0., 0., .5);
break;
case kFlatColorGreen:
glColor4f(0., 1., 0., .5);
break;
case kFlatColorYellow:
glColor4f(1., 1., 0., .5);
break;
case kFlatColorBlue:
glColor4f(0., 0., 1., .5);
break;
case kFlatColorShadow:
glColor4f(0., 0., 0., .5);
break;
case kFlatColorLight:
glColor4f(1., 1., 1., .2);
break;
default:
if (color >= 0 && color < 256) {
glColor4f(_pixelColorMap[0][color], _pixelColorMap[1][color], _pixelColorMap[2][color], _pixelColorMap[3][color]);
} else {
warning("Render::drawPolygonFlat() unhandled color %d", color);
}
break;
}
#ifdef PANDORA
/*
GLfloat nortemp[9],vertemp[9]; float ntemp;
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
while(verticesCount--){
vertemp[0]=vertices->x;vertemp[1]=vertices->y;vertemp[2]=vertices->z;
nortemp[0]=vertices->nx;nortemp[1]=vertices->ny;nortemp[2]=vertices->nz;vertices+=1;
vertemp[3]=vertices->x;vertemp[4]=vertices->y;vertemp[5]=vertices->z;
nortemp[3]=vertices->nx;nortemp[4]=vertices->ny;nortemp[5]=vertices->nz;vertices+=1;
vertemp[6]=vertices->x;vertemp[7]=vertices->y;vertemp[8]=vertices->z;
nortemp[6]=vertices->nx;nortemp[7]=vertices->ny;nortemp[8]=vertices->nz;vertices+=1;
ntemp=sqrt((nortemp[0]*nortemp[0])+(nortemp[1]*nortemp[1])+(nortemp[2]*nortemp[2]));
nortemp[0]/=ntemp;nortemp[1]/=ntemp;nortemp[2]/=ntemp;
ntemp=sqrt((nortemp[3]*nortemp[3])+(nortemp[4]*nortemp[4])+(nortemp[5]*nortemp[5]));
nortemp[3]/=ntemp;nortemp[4]/=ntemp;nortemp[5]/=ntemp;
ntemp=sqrt((nortemp[6]*nortemp[6])+(nortemp[7]*nortemp[7])+(nortemp[8]*nortemp[8]));
nortemp[6]/=ntemp;nortemp[7]/=ntemp;nortemp[8]/=ntemp;
glNormalPointer(GL_FLOAT, 0, nortemp);
glVertexPointer(3,GL_FLOAT,0,vertemp);
glDrawArrays(GL_TRIANGLE_FAN,0,3);
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
*/
int v,ni;
GLfloat vtx[verticesCount*3];
GLfloat nrm[verticesCount*3];
glEnableClientState(GL_VERTEX_ARRAY);
if (_normals) {
glEnableClientState(GL_NORMAL_ARRAY);
}
v = 0;
ni = 0;
while (verticesCount--)
{
vtx[v++] = vertices->x; vtx[v++] = vertices->y; vtx[v++] = vertices->z;
if (_normals) {
Vertex4f n;
n.x = vertices->nx; n.y = vertices->ny; n.z = vertices->nz;
n.normalize();
nrm[ni++] = n.x; nrm[ni++] = n.y; nrm[ni++] = n.z;
}
++vertices;
}
glVertexPointer(3, GL_FLOAT, 0, vtx);
if (_normals) {
glNormalPointer(GL_FLOAT,0,nrm);
}
//}
glDrawArrays(GL_TRIANGLE_FAN,0,verticesCount);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
#else
glBegin(GL_POLYGON);
while (verticesCount--) {
glVertex3f(vertices->x, vertices->y, vertices->z);
if (_normals) {
Vertex4f n;
n.x = vertices->nx;
n.y = vertices->ny;
n.z = vertices->nz;
n.normalize();
glNormal3f(n.x, n.y, n.z);
}
++vertices;
}
glEnd();
#endif
glColor4f(1., 1., 1., 1.);
}