16 {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},
17 {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0} };
19 {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4},
20 {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} };
28 for (i = 0; i < 6; i++) {
30 glNormal3fv(&
n[i][0]);
31 glVertex3fv(&
v[
faces[i][0]][0]);
32 glVertex3fv(&
v[
faces[i][1]][0]);
33 glVertex3fv(&
v[
faces[i][2]][0]);
34 glVertex3fv(&
v[
faces[i][3]][0]);
42 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
51 v[0][0] =
v[1][0] =
v[2][0] =
v[3][0] = -1;
52 v[4][0] =
v[5][0] =
v[6][0] =
v[7][0] = 1;
53 v[0][1] =
v[1][1] =
v[4][1] =
v[5][1] = -1;
54 v[2][1] =
v[3][1] =
v[6][1] =
v[7][1] = 1;
55 v[0][2] =
v[3][2] =
v[4][2] =
v[7][2] = 1;
56 v[1][2] =
v[2][2] =
v[5][2] =
v[6][2] = -1;
62 glEnable(GL_LIGHTING);
65 glEnable(GL_DEPTH_TEST);
68 glMatrixMode(GL_PROJECTION);
74 glMatrixMode(GL_MODELVIEW);
75 gluLookAt(0.0, 0.0, 5.0,
80 glTranslatef(0.0, 0.0, -1.0);
81 glRotatef(60, 1.0, 0.0, 0.0);
82 glRotatef(-20, 0.0, 0.0, 1.0);
88 glutInit(&argc, argv);
89 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
90 glutCreateWindow(
"red 3D lighted cube");
int main(int argc, char **argv)