1 | #include <GL/glut.h> |
---|
2 | #include <stdio.h> |
---|
3 | |
---|
4 | float rx, ry, rz; |
---|
5 | |
---|
6 | void display() |
---|
7 | { |
---|
8 | glClear(GL_COLOR_BUFFER_BIT); |
---|
9 | glColor3f(0.5, 0.4, 1.0); |
---|
10 | glPushMatrix(); |
---|
11 | glRotatef(rx, 1.0, 0.0, 0.0); |
---|
12 | glRotatef(ry, 0.0, 1.0, 0.0); |
---|
13 | glRotatef(rz, 0.0, 0.0, 1.0); |
---|
14 | glutWireTeapot(0.5); |
---|
15 | glPopMatrix(); |
---|
16 | glutSwapBuffers(); |
---|
17 | } |
---|
18 | |
---|
19 | void keyboard(unsigned char key, int x, int y) |
---|
20 | { |
---|
21 | //print *, 'Key ', char(key), key, ' at', x, y |
---|
22 | fprintf (stderr,"Key %c at %d, %d\n", key, x, y); |
---|
23 | if (key=='x') |
---|
24 | rx = rx + 5.0; |
---|
25 | if (key=='y') |
---|
26 | ry = ry + 5.0; |
---|
27 | if (key=='z') |
---|
28 | rz = rz + 5.0; |
---|
29 | glutPostRedisplay(); |
---|
30 | } |
---|
31 | |
---|
32 | int main(int argc, char *argv[]) |
---|
33 | { |
---|
34 | glutInit(&argc, argv); |
---|
35 | glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); |
---|
36 | glutCreateWindow("Use keys x, y, and z"); |
---|
37 | glutDisplayFunc(display); |
---|
38 | glutKeyboardFunc(keyboard); |
---|
39 | glutMainLoop(); |
---|
40 | return 0; |
---|
41 | } |
---|