1 
2 enum {
3     COLOR_BLACK = 0,
4     COLOR_RED,
5     COLOR_GREEN,
6     COLOR_YELLOW,
7     COLOR_BLUE,
8     COLOR_MAGENTA,
9     COLOR_CYAN,
10     COLOR_WHITE
11 };
12 
13 static float RGBMap[9][3] = {
14     {0, 0, 0},
15     {1, 0, 0},
16     {0, 1, 0},
17     {1, 1, 0},
18     {0, 0, 1},
19     {1, 0, 1},
20     {0, 1, 1},
21     {1, 1, 1},
22     {0.5, 0.5, 0.5}
23 };
24 
SetColor(int c)25 static void SetColor(int c)
26 {
27     if (glutGet(GLUT_WINDOW_RGBA))
28         glColor3fv(RGBMap[c]);
29     else
30         glIndexf(c);
31 }
32 
InitMap(void)33 static void InitMap(void)
34 {
35     int i;
36 
37     if (rgb)
38 	return;
39 
40     for (i = 0; i < 9; i++)
41 	    glutSetColor(i, RGBMap[i][0], RGBMap[i][1], RGBMap[i][2]);
42 }
43 
SetFogRamp(int density,int startIndex)44 static void SetFogRamp(int density, int startIndex)
45 {
46     int fogValues, colorValues;
47     int i, j, k;
48     float intensity;
49 
50     fogValues = 1 << density;
51     colorValues = 1 << startIndex;
52     for (i = 0; i < colorValues; i++) {
53 	for (j = 0; j < fogValues; j++) {
54 	    k = i * fogValues + j;
55 	    intensity = (i * fogValues + j * colorValues) / 255.0;
56 	    glutSetColor(k, intensity, intensity, intensity);
57 	}
58     }
59 }
60 
SetGreyRamp(void)61 static void SetGreyRamp(void)
62 {
63     int i;
64     float intensity;
65 
66     for (i = 0; i < 255; i++) {
67 	intensity = i / 255.0;
68 	glutSetColor(i, intensity, intensity, intensity);
69     }
70 }
71 
72