7 int mouse_x, mouse_y, mouse_state[3];
8 int win_width, win_height;
11 struct game_screen *cur_scr;
13 /* available screens */
14 extern struct game_screen scr_menu, scr_game;
16 static struct game_screen *screens[MAX_SCREENS];
17 static int num_screens;
25 /* initialize screens */
26 screens[num_screens++] = &scr_menu;
27 screens[num_screens++] = &scr_game;
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.1, 0.1, 0.1, 1);
44 glEnable(GL_DEPTH_TEST);
45 glEnable(GL_CULL_FACE);
46 glEnable(GL_LIGHTING);
51 void game_shutdown(void)
55 for(i=0; i<num_screens; i++) {
56 if(screens[i]->destroy) {
57 screens[i]->destroy();
62 void game_display(void)
64 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
71 void game_reshape(int x, int y)
75 win_aspect = (float)x / (float)y;
76 glViewport(0, 0, x, y);
78 glMatrixMode(GL_PROJECTION);
80 gluPerspective(50, win_aspect, 0.5, 500);
82 if(cur_scr && cur_scr->reshape) {
83 cur_scr->reshape(x, y);
87 void game_keyboard(int key, int press)
97 if(cur_scr && cur_scr->keyboard) {
98 cur_scr->keyboard(key, press);
102 void game_mouse(int bn, int st, int x, int y)
107 mouse_state[bn] = st;
110 if(cur_scr && cur_scr->mouse) {
111 cur_scr->mouse(bn, st, x, y);
115 void game_motion(int x, int y)
117 if(cur_scr && cur_scr->motion) {
118 cur_scr->motion(x, y);
124 void game_chscr(struct game_screen *scr)
128 if(scr->start && scr->start() == -1) {
132 if(cur_scr && cur_scr->stop) {