1#ifndef PLATFORM_H
2#define PLATFORM_H
3
4#include "types.h"
5#include "platform/keys.h"
6
7/* clang-format off */
8#ifdef MG_PLATFORM_SDL
9 #include "platform/platform_sdl.h"
10#elif MG_PLATFORM_MAUS
11 #include "platform/platform_maus.h"
12#endif
13/* clang-format on */
14
15typedef struct {
16 MGWindow* win;
17 MGVidBE vbe;
18 const char* title;
19 i32 x;
20 i32 y;
21 i32 width;
22 i32 height;
23 MGKey keys[MG_KEYS_DOWN_MAX];
24} MGContext;
25
26/* get drawable screen size. usually different due to hi-dpi options */
27void platform_get_drawable_size(MGContext* ctx, i32* width, i32* height);
28
29/* store mouse position in x and y */
30void platform_get_mouse_state(i32* x, i32* y);
31
32/* get time from initialisation of windowing backend
33 returns time in ms */
34u64 platform_get_ticks(void);
35
36/* initialise resources */
37void platform_init(MGContext* ctx);
38
39/* check if a logical key is pressed */
40i32 platform_key_down(MGContext* ctx, MGKey key);
41
42/* poll for next events */
43i32 platform_poll(MGContext* ctx);
44
45/* present next buffer to screen */
46void platform_present(MGContext* ctx);
47
48/* enable or disable relative mouse mode */
49void platform_set_mouse_relative(i8 enabled);
50
51/* shutdown `ctx` */
52void platform_shutdown(MGContext* ctx);
53
54/* create window */
55void platform_window_create(MGContext* ctx);
56
57/* delay for specified ms */
58void platform_wait(u32 ms);
59
60#endif /* PLATFORM_H */