rev |
line source |
nuclear@0
|
1 #include <stdio.h>
|
nuclear@0
|
2 #include <stdlib.h>
|
nuclear@0
|
3 #include <assert.h>
|
nuclear@0
|
4
|
nuclear@0
|
5 #ifndef __APPLE__
|
nuclear@0
|
6 #include <GL/glut.h>
|
nuclear@0
|
7 #else
|
nuclear@0
|
8 #include <GLUT/glut.h>
|
nuclear@0
|
9 #endif
|
nuclear@0
|
10
|
nuclear@0
|
11 static bool init();
|
nuclear@0
|
12 static void cleanup();
|
nuclear@0
|
13 static void display();
|
nuclear@0
|
14 static void idle();
|
nuclear@0
|
15 static void reshape(int x, int y);
|
nuclear@0
|
16 static void keyb(unsigned char key, int x, int y);
|
nuclear@0
|
17 static void mouse(int bn, int st, int x, int y);
|
nuclear@0
|
18 static void motion(int x, int y);
|
nuclear@0
|
19
|
nuclear@0
|
20
|
nuclear@0
|
21 int main(int argc, char **argv)
|
nuclear@0
|
22 {
|
nuclear@0
|
23 glutInit(&argc, argv);
|
nuclear@0
|
24 glutInitWindowSize(800, 600);
|
nuclear@0
|
25 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
nuclear@0
|
26 glutCreateWindow("component system test");
|
nuclear@0
|
27
|
nuclear@0
|
28 glutDisplayFunc(display);
|
nuclear@0
|
29 glutIdleFunc(idle);
|
nuclear@0
|
30 glutReshapeFunc(reshape);
|
nuclear@0
|
31 glutKeyboardFunc(keyb);
|
nuclear@0
|
32 glutMouseFunc(mouse);
|
nuclear@0
|
33 glutMotionFunc(motion);
|
nuclear@0
|
34
|
nuclear@0
|
35 if(!init()) {
|
nuclear@0
|
36 return 1;
|
nuclear@0
|
37 }
|
nuclear@0
|
38 atexit(cleanup);
|
nuclear@0
|
39
|
nuclear@0
|
40 glutMainLoop();
|
nuclear@0
|
41 return 0;
|
nuclear@0
|
42 }
|
nuclear@0
|
43
|
nuclear@0
|
44 static bool init()
|
nuclear@0
|
45 {
|
nuclear@0
|
46 glEnable(GL_DEPTH_TEST);
|
nuclear@0
|
47 glEnable(GL_CULL_FACE);
|
nuclear@0
|
48
|
nuclear@0
|
49 return true;
|
nuclear@0
|
50 }
|
nuclear@0
|
51
|
nuclear@0
|
52 static void cleanup()
|
nuclear@0
|
53 {
|
nuclear@0
|
54 }
|
nuclear@0
|
55
|
nuclear@0
|
56 static void display()
|
nuclear@0
|
57 {
|
nuclear@0
|
58 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
nuclear@0
|
59
|
nuclear@0
|
60 glutSwapBuffers();
|
nuclear@0
|
61 assert(glGetError() == GL_NO_ERROR);
|
nuclear@0
|
62 }
|
nuclear@0
|
63
|
nuclear@0
|
64 static void idle()
|
nuclear@0
|
65 {
|
nuclear@0
|
66 glutPostRedisplay();
|
nuclear@0
|
67 }
|
nuclear@0
|
68
|
nuclear@0
|
69 static void reshape(int x, int y)
|
nuclear@0
|
70 {
|
nuclear@0
|
71 glViewport(0, 0, x, y);
|
nuclear@0
|
72
|
nuclear@2
|
73 glMatrixMode(GL_PROJECTION);
|
nuclear@0
|
74 glLoadIdentity();
|
nuclear@0
|
75 gluPerspective(50.0, (float)x / (float)y, 0.5, 500.0);
|
nuclear@0
|
76 }
|
nuclear@0
|
77
|
nuclear@0
|
78 static void keyb(unsigned char key, int x, int y)
|
nuclear@0
|
79 {
|
nuclear@0
|
80 switch(key) {
|
nuclear@0
|
81 case 27:
|
nuclear@0
|
82 exit(0);
|
nuclear@0
|
83 }
|
nuclear@0
|
84 }
|
nuclear@0
|
85
|
nuclear@0
|
86 static int bnstate[16];
|
nuclear@0
|
87 static int prev_x, prev_y;
|
nuclear@0
|
88
|
nuclear@0
|
89 static void mouse(int bn, int st, int x, int y)
|
nuclear@0
|
90 {
|
nuclear@0
|
91 }
|
nuclear@0
|
92
|
nuclear@0
|
93 static void motion(int x, int y)
|
nuclear@0
|
94 {
|
nuclear@0
|
95 }
|