2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
20 /*---------------------------------------------------------------------------*/
22 static float state_time;
23 static int state_drawn;
24 static struct state *state;
26 struct state *curr_state(void)
31 float time_state(void)
36 void init_state(struct state *st)
41 int goto_state(struct state *st)
43 if (state && state->leave)
44 state->leave(state->gui_id);
50 if (state && state->enter)
51 state->gui_id = state->enter();
56 /*---------------------------------------------------------------------------*/
58 void st_paint(float t)
60 int stereo = config_get_d(CONFIG_STEREO);
64 if (state && state->paint)
68 glDrawBuffer(GL_BACK_LEFT);
70 state->paint(state->gui_id, t);
72 glDrawBuffer(GL_BACK_RIGHT);
74 state->paint(state->gui_id, t);
79 state->paint(state->gui_id, t);
84 void st_timer(float dt)
91 if (state && state->timer)
92 state->timer(state->gui_id, dt);
95 void st_point(int x, int y, int dx, int dy)
97 if (state && state->point)
98 state->point(state->gui_id, x, y, dx, dy);
101 void st_stick(int a, int k)
103 if (state && state->stick)
104 state->stick(state->gui_id, a, k);
107 void st_angle(int x, int z)
109 if (state && state->angle)
110 state->angle(state->gui_id, x, z);
113 /*---------------------------------------------------------------------------*/
115 int st_click(int b, int d)
117 return (state && state->click) ? state->click(b, d) : 1;
120 int st_keybd(int c, int d)
122 return (state && state->keybd) ? state->keybd(c, d) : 1;
125 int st_buttn(int b, int d)
127 return (state && state->buttn) ? state->buttn(b, d) : 1;
130 /*---------------------------------------------------------------------------*/