132001f49Smrg
232001f49Smrgenum {
332001f49Smrg    COLOR_BLACK = 0,
432001f49Smrg    COLOR_RED,
532001f49Smrg    COLOR_GREEN,
632001f49Smrg    COLOR_YELLOW,
732001f49Smrg    COLOR_BLUE,
832001f49Smrg    COLOR_MAGENTA,
932001f49Smrg    COLOR_CYAN,
1032001f49Smrg    COLOR_WHITE
1132001f49Smrg};
1232001f49Smrg
1332001f49Smrgstatic float RGBMap[9][3] = {
1432001f49Smrg    {0, 0, 0},
1532001f49Smrg    {1, 0, 0},
1632001f49Smrg    {0, 1, 0},
1732001f49Smrg    {1, 1, 0},
1832001f49Smrg    {0, 0, 1},
1932001f49Smrg    {1, 0, 1},
2032001f49Smrg    {0, 1, 1},
2132001f49Smrg    {1, 1, 1},
2232001f49Smrg    {0.5, 0.5, 0.5}
2332001f49Smrg};
2432001f49Smrg
2532001f49Smrgstatic void SetColor(int c)
2632001f49Smrg{
2732001f49Smrg    if (glutGet(GLUT_WINDOW_RGBA))
2832001f49Smrg        glColor3fv(RGBMap[c]);
2932001f49Smrg    else
3032001f49Smrg        glIndexf(c);
3132001f49Smrg}
3232001f49Smrg
3332001f49Smrgstatic void InitMap(void)
3432001f49Smrg{
3532001f49Smrg    int i;
3632001f49Smrg
3732001f49Smrg    if (rgb)
3832001f49Smrg	return;
3932001f49Smrg
4032001f49Smrg    for (i = 0; i < 9; i++)
4132001f49Smrg	    glutSetColor(i, RGBMap[i][0], RGBMap[i][1], RGBMap[i][2]);
4232001f49Smrg}
4332001f49Smrg
4432001f49Smrgstatic void SetFogRamp(int density, int startIndex)
4532001f49Smrg{
4632001f49Smrg    int fogValues, colorValues;
4732001f49Smrg    int i, j, k;
4832001f49Smrg    float intensity;
4932001f49Smrg
5032001f49Smrg    fogValues = 1 << density;
5132001f49Smrg    colorValues = 1 << startIndex;
5232001f49Smrg    for (i = 0; i < colorValues; i++) {
5332001f49Smrg	for (j = 0; j < fogValues; j++) {
5432001f49Smrg	    k = i * fogValues + j;
5532001f49Smrg	    intensity = (i * fogValues + j * colorValues) / 255.0;
5632001f49Smrg	    glutSetColor(k, intensity, intensity, intensity);
5732001f49Smrg	}
5832001f49Smrg    }
5932001f49Smrg}
6032001f49Smrg
6132001f49Smrgstatic void SetGreyRamp(void)
6232001f49Smrg{
6332001f49Smrg    int i;
6432001f49Smrg    float intensity;
6532001f49Smrg
6632001f49Smrg    for (i = 0; i < 255; i++) {
6732001f49Smrg	intensity = i / 255.0;
6832001f49Smrg	glutSetColor(i, intensity, intensity, intensity);
6932001f49Smrg    }
7032001f49Smrg}
7132001f49Smrg
72