integrating software renderer
[retroray] / src / app.h
1 /*
2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023  John Tsiombikas <nuclear@mutantstargoat.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #ifndef APP_H_
19 #define APP_H_
20
21 #include "sizeint.h"
22 #include "logger.h"
23
24 enum {
25         KEY_ESC = 27,
26         KEY_DEL = 127,
27         KEY_F1          = 256,
28         KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7,
29         KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
30         KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,
31         KEY_PGUP, KEY_PGDOWN,
32         KEY_HOME, KEY_END,
33         KEY_INS
34 };
35
36 enum {
37         KEY_MOD_SHIFT   = 1,
38         KEY_MOD_CTRL    = 4,
39         KEY_MOD_ALT     = 8
40 };
41
42
43 struct app_screen {
44         const char *name;
45
46         int (*init)(void);
47         void (*destroy)(void);
48         int (*start)(void);
49         void (*stop)(void);
50         void (*display)(void);
51         void (*reshape)(int, int);
52         void (*keyboard)(int, int);
53         void (*mouse)(int, int, int, int);
54         void (*motion)(int, int);
55         void (*sball_motion)(int, int, int);
56         void (*sball_rotate)(int, int, int);
57         void (*sball_button)(int, int);
58 };
59
60 extern int mouse_x, mouse_y, mouse_state[3];
61 extern unsigned int modkeys;
62 extern int win_width, win_height;
63 extern float win_aspect;
64 extern int fullscr;
65
66 extern long time_msec;
67 extern struct app_screen *cur_scr;
68 extern struct app_screen scr_model, scr_rend;
69
70 struct font;
71 extern struct font *uifont;
72
73 extern uint32_t *framebuf;
74
75
76 int app_init(void);
77 void app_shutdown(void);
78
79 void app_display(void);
80 void app_reshape(int x, int y);
81 void app_keyboard(int key, int press);
82 void app_mouse(int bn, int st, int x, int y);
83 void app_motion(int x, int y);
84 void app_sball_motion(int x, int y, int z);
85 void app_sball_rotate(int x, int y, int z);
86 void app_sball_button(int bn, int st);
87
88 void app_chscr(struct app_screen *scr);
89
90 /* defined in main.c */
91 long app_getmsec(void);
92 void app_redisplay(void);
93 void app_swap_buffers(void);
94 void app_quit(void);
95 void app_resize(int x, int y);
96 void app_fullscreen(int fs);
97 void app_vsync(int vsync);
98
99 #endif  /* APP_H_ */