added tunnel effect and SDL backend
[dosdemo] / src / demo.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <math.h>
5 #include <errno.h>
6 #include "demo.h"
7 #include "screen.h"
8
9 int fb_width = 320;
10 int fb_height = 240;
11 int fb_bpp = 16;
12 unsigned char *fb_pixels;
13 unsigned long time_msec;
14
15 static unsigned long nframes;
16
17 int demo_init(int argc, char **argv)
18 {
19         if(scr_init() == -1) {
20                 return -1;
21         }
22         scr_change(scr_lookup("tunnel"), 4000);
23
24         return 0;
25 }
26
27 void demo_cleanup(void)
28 {
29         scr_shutdown();
30
31         if(time_msec) {
32                 float fps = (float)nframes / ((float)time_msec / 1000.0f);
33                 printf("average framerate: %.1f\n", fps);
34         }
35 }
36
37 void demo_draw(void)
38 {
39         scr_update();
40         scr_draw();
41
42         ++nframes;
43 }
44
45 void demo_keyboard(int key, int state)
46 {
47         if(state) {
48                 switch(key) {
49                 case 27:
50                         demo_quit();
51                         break;
52
53                 default:
54                         break;
55                 }
56         }
57 }