6 int mouse_x, mouse_y, mouse_state[3];
7 int win_width, win_height;
10 struct game_screen *cur_scr;
12 /* available screens */
13 extern struct game_screen scr_menu, scr_game, scr_map;
15 static struct game_screen *screens[MAX_SCREENS];
16 static int num_screens;
24 /* initialize screens */
25 screens[num_screens++] = &scr_menu;
26 screens[num_screens++] = &scr_game;
27 screens[num_screens++] = &scr_map;
29 start_scr_name = getenv("START_SCREEN");
31 for(i=0; i<num_screens; i++) {
32 if(screens[i]->init() == -1) {
35 if(screens[i]->name && start_scr_name && strcmp(screens[i]->name, start_scr_name) == 0) {
36 game_chscr(screens[i]);
40 game_chscr(&scr_game); /* TODO: scr_menu */
43 glClearColor(0.3, 0.3, 0.3, 1);
47 void game_shutdown(void)
51 for(i=0; i<num_screens; i++) {
52 if(screens[i]->destroy) {
53 screens[i]->destroy();
58 void game_display(void)
60 glClear(GL_COLOR_BUFFER_BIT);
69 void game_reshape(int x, int y)
73 win_aspect = (float)x / (float)y;
74 glViewport(0, 0, x, y);
76 if(cur_scr && cur_scr->reshape) {
77 cur_scr->reshape(x, y);
81 void game_keyboard(int key, int press)
91 if(cur_scr && cur_scr->keyboard) {
92 cur_scr->keyboard(key, press);
96 void game_mouse(int bn, int st, int x, int y)
101 mouse_state[bn] = st;
104 if(cur_scr && cur_scr->mouse) {
105 cur_scr->mouse(bn, st, x, y);
109 void game_motion(int x, int y)
114 if(cur_scr && cur_scr->motion) {
115 cur_scr->motion(x, y);
119 void game_chscr(struct game_screen *scr)
123 if(scr->start && scr->start() == -1) {
127 if(cur_scr && cur_scr->stop) {