unsigned char colors[3*(facets+1)] = {0};
// distribute over 3 colours as one number
int pi = 255*255*255 / (facets+1);
int cval;
for (i = 0; i < facets; i++)
{
cval = pi * (i+1);
// shift 8 bits
cval = cval << 8;
memcpy(colors + 3*i, &cval, 3);
}
// disable any lights, smoothness, materials etc
glClearColor(0,0,0,0);
// render here using:
glColorubv(colors + 3*current_facet);
// swapbuffers
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glReadPixels(0,0,width,height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
int visible[facets] = {0};
for ( y ... )
for (x ...)
if (pixel is black) continue;
for each color used C
if (visible[C]) break;
if pixel color is one of those used
{
visible[C] = 1;
break;
}