6638b4e45ab14eb58fabd303034a9b60e545bd7a
[vrtris] / src / screen.c
1 #include "screen.h"
2
3 static struct game_screen *screens[16];
4 static int num_screens;
5
6 static struct game_screen *stack;
7
8 int init_screens(void)
9 {
10         int i;
11
12         for(i=0; i<num_screens; i++) {
13                 if(screens[i]->init() == -1) {
14                         return -1;
15                 }
16         }
17         return 0;
18 }
19
20 void cleanup_screens(void)
21 {
22         int i;
23
24         for(i=0; i<num_screens; i++) {
25                 screens[i]->cleanup();
26         }
27 }
28
29 void reshape_screens(int x, int y)
30 {
31         struct game_screen *s = stack;
32         while(s) {
33                 s->reshape(x, y);
34                 s = s->next;
35         }
36 }
37
38 void push_screen(struct game_screen *s)
39 {
40         s->next = stack;
41         stack = s;
42         s->start();
43 }
44
45 int pop_screen(void)
46 {
47         struct game_screen *s;
48
49         if(!stack->next) return -1;
50         s = stack;
51         stack = stack->next;
52         s->stop();
53         return 0;
54 }