8 int mouse_x, mouse_y, mouse_state[3];
9 int win_width, win_height;
12 struct game_screen *cur_scr;
14 /* available screens */
15 extern struct game_screen scr_menu, scr_game;
17 static struct game_screen *screens[MAX_SCREENS];
18 static int num_screens;
26 /* initialize screens */
27 screens[num_screens++] = &scr_menu;
28 screens[num_screens++] = &scr_game;
30 start_scr_name = getenv("START_SCREEN");
32 for(i=0; i<num_screens; i++) {
33 if(screens[i]->init() == -1) {
36 if(screens[i]->name && start_scr_name && strcmp(screens[i]->name, start_scr_name) == 0) {
37 game_chscr(screens[i]);
41 game_chscr(&scr_game); /* TODO: scr_menu */
46 glClearColor(0.1, 0.1, 0.1, 1);
47 glEnable(GL_DEPTH_TEST);
48 glEnable(GL_CULL_FACE);
49 glEnable(GL_LIGHTING);
54 void game_shutdown(void)
58 for(i=0; i<num_screens; i++) {
59 if(screens[i]->destroy) {
60 screens[i]->destroy();
65 void game_display(void)
67 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
74 void game_reshape(int x, int y)
78 win_aspect = (float)x / (float)y;
79 glViewport(0, 0, x, y);
81 glMatrixMode(GL_PROJECTION);
83 gluPerspective(50, win_aspect, 0.5, 500);
85 if(cur_scr && cur_scr->reshape) {
86 cur_scr->reshape(x, y);
90 void game_keyboard(int key, int press)
100 if(cur_scr && cur_scr->keyboard) {
101 cur_scr->keyboard(key, press);
105 void game_mouse(int bn, int st, int x, int y)
110 mouse_state[bn] = st;
113 if(cur_scr && cur_scr->mouse) {
114 cur_scr->mouse(bn, st, x, y);
118 void game_motion(int x, int y)
120 if(cur_scr && cur_scr->motion) {
121 cur_scr->motion(x, y);
127 void game_chscr(struct game_screen *scr)
131 if(scr->start && scr->start() == -1) {
135 if(cur_scr && cur_scr->stop) {