rev |
line source |
nuclear@26
|
1 #include <stdio.h>
|
nuclear@26
|
2 #include <stdlib.h>
|
nuclear@26
|
3 #include "opengl.h"
|
nuclear@26
|
4 #include <GL/glut.h>
|
nuclear@26
|
5 #include "game.h"
|
nuclear@26
|
6 #include "camera.h"
|
nuclear@26
|
7 #include "timer.h"
|
nuclear@26
|
8
|
nuclear@26
|
9 static int init(void);
|
nuclear@26
|
10 static void cleanup(void);
|
nuclear@26
|
11 static void display(void);
|
nuclear@26
|
12 static void idle(void);
|
nuclear@26
|
13 static void reshape(int x, int y);
|
nuclear@26
|
14 static void keyb(unsigned char key, int x, int y);
|
nuclear@26
|
15 static void keyb_release(unsigned char key, int x, int y);
|
nuclear@26
|
16 static void mouse(int bn, int state, int x, int y);
|
nuclear@26
|
17 static void motion(int x, int y);
|
nuclear@26
|
18 static void sball_motion(int x, int y, int z);
|
nuclear@26
|
19 static void sball_rotate(int x, int y, int z);
|
nuclear@26
|
20
|
nuclear@26
|
21 int main(int argc, char **argv)
|
nuclear@26
|
22 {
|
nuclear@26
|
23 glutInit(&argc, argv);
|
nuclear@26
|
24 glutInitWindowSize(800, 600);
|
nuclear@26
|
25 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
nuclear@26
|
26 glutCreateWindow("3dphotoshoot (PC)");
|
nuclear@26
|
27
|
nuclear@26
|
28 glutDisplayFunc(display);
|
nuclear@26
|
29 glutIdleFunc(idle);
|
nuclear@26
|
30 glutReshapeFunc(reshape);
|
nuclear@26
|
31 glutKeyboardFunc(keyb);
|
nuclear@26
|
32 glutKeyboardUpFunc(keyb_release);
|
nuclear@26
|
33 glutMouseFunc(mouse);
|
nuclear@26
|
34 glutMotionFunc(motion);
|
nuclear@26
|
35 glutSpaceballMotionFunc(sball_motion);
|
nuclear@26
|
36 glutSpaceballRotateFunc(sball_rotate);
|
nuclear@26
|
37
|
nuclear@26
|
38 if(init() == -1) {
|
nuclear@26
|
39 return 1;
|
nuclear@26
|
40 }
|
nuclear@26
|
41 atexit(cleanup);
|
nuclear@26
|
42
|
nuclear@26
|
43 glutMainLoop();
|
nuclear@26
|
44 return 0;
|
nuclear@26
|
45 }
|
nuclear@26
|
46
|
nuclear@26
|
47 static int init(void)
|
nuclear@26
|
48 {
|
nuclear@26
|
49 glewInit();
|
nuclear@26
|
50
|
nuclear@26
|
51 if(cam_init(0) == -1) {
|
nuclear@26
|
52 return -1;
|
nuclear@26
|
53 }
|
nuclear@26
|
54
|
nuclear@26
|
55 if(game_init() == -1) {
|
nuclear@26
|
56 return -1;
|
nuclear@26
|
57 }
|
nuclear@26
|
58 return 0;
|
nuclear@26
|
59 }
|
nuclear@26
|
60
|
nuclear@26
|
61 static void cleanup(void)
|
nuclear@26
|
62 {
|
nuclear@26
|
63 game_shutdown();
|
nuclear@26
|
64 }
|
nuclear@26
|
65
|
nuclear@26
|
66 static void display(void)
|
nuclear@26
|
67 {
|
nuclear@26
|
68 game_display(get_time_msec());
|
nuclear@26
|
69 glutSwapBuffers();
|
nuclear@26
|
70 }
|
nuclear@26
|
71
|
nuclear@26
|
72 static void idle(void)
|
nuclear@26
|
73 {
|
nuclear@26
|
74 glutPostRedisplay();
|
nuclear@26
|
75 }
|
nuclear@26
|
76
|
nuclear@26
|
77 static void reshape(int x, int y)
|
nuclear@26
|
78 {
|
nuclear@26
|
79 game_reshape(x, y);
|
nuclear@26
|
80 }
|
nuclear@26
|
81
|
nuclear@26
|
82 static void keyb(unsigned char key, int x, int y)
|
nuclear@26
|
83 {
|
nuclear@26
|
84 switch(key) {
|
nuclear@26
|
85 case 27:
|
nuclear@26
|
86 exit(0);
|
nuclear@26
|
87 }
|
nuclear@26
|
88
|
nuclear@26
|
89 game_keyboard(key, 1);
|
nuclear@26
|
90 }
|
nuclear@26
|
91
|
nuclear@26
|
92 static void keyb_release(unsigned char key, int x, int y)
|
nuclear@26
|
93 {
|
nuclear@26
|
94 game_keyboard(key, 0);
|
nuclear@26
|
95 }
|
nuclear@26
|
96
|
nuclear@26
|
97 static void mouse(int bn, int state, int x, int y)
|
nuclear@26
|
98 {
|
nuclear@26
|
99 game_mouse_button(0, bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y);
|
nuclear@26
|
100 }
|
nuclear@26
|
101
|
nuclear@26
|
102 static void motion(int x, int y)
|
nuclear@26
|
103 {
|
nuclear@26
|
104 game_mouse_motion(0, x, y);
|
nuclear@26
|
105 }
|
nuclear@26
|
106
|
nuclear@26
|
107 static void sball_motion(int x, int y, int z)
|
nuclear@26
|
108 {
|
nuclear@26
|
109 }
|
nuclear@26
|
110
|
nuclear@26
|
111 static void sball_rotate(int x, int y, int z)
|
nuclear@26
|
112 {
|
nuclear@26
|
113 }
|