5a846ed124dd6389a421da082905b59c953d0d00
[vrlugburz] / src / game.c
1 #include <assert.h>
2 #include "game.h"
3 #include "opengl.h"
4 #include "level.h"
5
6 struct level lvl;
7
8 int game_init(void)
9 {
10         if(init_opengl() == -1) {
11                 return -1;
12         }
13
14         if(load_level(&lvl, "data/test.lvl") == -1) {
15                 return -1;
16         }
17
18         return 0;
19 }
20
21 void game_shutdown(void)
22 {
23         destroy_level(&lvl);
24 }
25
26 void game_display(void)
27 {
28         glClearColor(1, 0, 0, 1);
29         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
30
31         game_swap_buffers();
32         assert(glGetError() == GL_NO_ERROR);
33 }
34
35 void game_reshape(int x, int y)
36 {
37         glViewport(0, 0, x, y);
38 }
39
40 void game_keyboard(int key, int press)
41 {
42         if(press && key == 27) {
43                 game_quit();
44                 return;
45         }
46 }
47
48 void game_mbutton(int bn, int press, int x, int y)
49 {
50 }
51
52 void game_mmotion(int x, int y)
53 {
54 }