6 static const float black
[4] = { 0, 0, 0, 1 };
7 static const float white
[4] = { 1, 1, 1, 1 };
8 static const float diffuse
[4] = { 1, 0, 0, 1 };
9 static const float diffuseb
[4] = { 0, 1, 0, 1 };
10 static const float specular
[4] = { 0.5, 0.5, 0.5, 1 };
11 static const float ambient
[4] = { 0.2, 0.2, 0.2, 1 };
12 static const float lightpos
[4] = { 0, 0, 10, 0 };
13 static const float shininess
= 50;
15 static double angle
= 0.0;
17 static int autorotate
= 1;
18 static double angle_delta
= 1.0;
19 static int timeout
= 10;
25 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
27 glRotated(angle
, 0.0, 1.0, 0.0);
32 glVertex3d(-1, -1, 0);
33 glVertex3d(+1, -1, 0);
34 glVertex3d(+1, +1, 0);
35 glVertex3d(-1, +1, 0);
48 glutTimerFunc(timeout
, timer
, 0);
54 key(unsigned char key
, int x
, int y
)
63 main(int argc
, char **argv
)
66 glutInit(&argc
, argv
);
67 glutInitDisplayMode(GLUT_DOUBLE
| GLUT_RGBA
| GLUT_DEPTH
);
68 glutCreateWindow("Backface specular test");
69 glutDisplayFunc(display
);
70 glutKeyboardFunc(key
);
72 glutTimerFunc(timeout
, timer
, 0);
75 glMaterialfv(GL_FRONT
, GL_DIFFUSE
, diffuse
);
76 glMaterialfv(GL_BACK
, GL_DIFFUSE
, diffuseb
);
78 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, black
);
79 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, specular
);
80 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, ambient
);
81 glMaterialf (GL_FRONT_AND_BACK
, GL_SHININESS
, shininess
);
83 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, GL_FALSE
);
84 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL
, GL_SEPARATE_SPECULAR_COLOR
);
85 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE
, GL_TRUE
);
87 glLightfv(GL_LIGHT0
, GL_AMBIENT
, black
);
88 glLightfv(GL_LIGHT0
, GL_DIFFUSE
, white
);
89 glLightfv(GL_LIGHT0
, GL_POSITION
, lightpos
);
90 glLightfv(GL_LIGHT0
, GL_SPECULAR
, white
);
92 glDisable(GL_CULL_FACE
);
93 glEnable(GL_LIGHTING
);
97 glMatrixMode(GL_PROJECTION
);
98 gluPerspective(30.0, 1.0, 1.0, 10.0);
99 glMatrixMode(GL_MODELVIEW
);
100 gluLookAt(0.0, 0.0, 5.0,
105 glEnable(GL_DEPTH_TEST
);
106 glClearColor(0, 0, 1, 1);