1#ifndef PLATFORM_H
2#define PLATFORM_H
3
4#include <SDL2/SDL.h>
5
6#include "types.h"
7
8typedef SDL_Window MGWindow;
9
10typedef struct {
11#ifdef MG_RENDERER_SMALL3DLIB
12 SDL_Renderer* renderer;
13#endif
14#ifdef MG_RENDERER_SOKOL
15 SDL_GLContext gl;
16#endif
17} MGVidBE;
18
19typedef struct {
20 MGWindow* win;
21 MGVidBE vbe;
22 const char* title;
23 i32 x;
24 i32 y;
25 i32 width;
26 i32 height;
27} MGContext;
28
29/* get drawable screen size. usually different due to hi-dpi options
30 > probably can stub out on software renderer */
31void platform_get_drawable_size(MGContext* ctx, i32* width, i32* height);
32
33/* initialise resources */
34void platform_init(MGContext* ctx);
35
36/* poll for next events */
37i32 platform_poll(MGContext* ctx);
38
39/* present next buffer to screen */
40void platform_present(MGContext* ctx);
41
42/* shutdown `ctx` */
43void platform_shutdown(MGContext* ctx);
44
45/* create window */
46void platform_window_create(MGContext* ctx);
47
48#endif /* PLATFORM_H */