diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-19 22:12:52 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-19 22:12:52 +0200 |
commit | 9da3c2188060dc982412d7a6e1cd2051b9ddb6a6 (patch) | |
tree | 18d7cd9ec63c1f2e42dcda3941907f32e34ac241 /include/mgl/window | |
parent | 3bdf82eec2c915e91ae487e29d72639f9efcad67 (diff) |
Change from callback to window poll
Diffstat (limited to 'include/mgl/window')
-rw-r--r-- | include/mgl/window/event.h | 10 | ||||
-rw-r--r-- | include/mgl/window/window.h | 23 |
2 files changed, 22 insertions, 11 deletions
diff --git a/include/mgl/window/event.h b/include/mgl/window/event.h new file mode 100644 index 0000000..2aea478 --- /dev/null +++ b/include/mgl/window/event.h @@ -0,0 +1,10 @@ +#ifndef MGL_EVENT_H +#define MGL_EVENT_H + +typedef struct mgl_event mgl_event; + +struct mgl_event { + int type; +}; + +#endif /* MGL_EVENT_H */ diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h index 5232260..d66fa71 100644 --- a/include/mgl/window/window.h +++ b/include/mgl/window/window.h @@ -1,28 +1,29 @@ #ifndef MGL_WINDOW_H #define MGL_WINDOW_H +#include "../graphics/color.h" #include "../system/vec.h" +#include <stdbool.h> -typedef struct mgl_window mgl_window; +typedef struct mgl_event mgl_event; +/* x11 window handle. TODO: Add others when wayland, etc is added */ +typedef unsigned long mgl_window_handle; -typedef struct { - void *userdata; - void (*draw)(mgl_window *window, void *userdata); -} mgl_window_callback; +typedef struct mgl_window mgl_window; struct mgl_window { - unsigned long window; - mgl_window_callback callback; + mgl_window_handle window; mgl_vec2i size; mgl_vec2i cursor_position; }; -int mgl_window_create(mgl_window *self, const char *title, int width, int height, mgl_window_callback *callback); +int mgl_window_create(mgl_window *self, const char *title, int width, int height); /* if |parent_window| is 0 then the root window is used */ -int mgl_window_create_with_params(mgl_window *self, const char *title, int width, int height, unsigned long parent_window, mgl_window_callback *callback); +int mgl_window_create_with_params(mgl_window *self, const char *title, int width, int height, mgl_window_handle parent_window); void mgl_window_deinit(mgl_window *self); -void mgl_window_events_poll(mgl_window *self); -void mgl_window_draw(mgl_window *self); +void mgl_window_clear(mgl_window *self, mgl_color color); +bool mgl_window_events_poll(mgl_window *self, mgl_event *event); +void mgl_window_display(mgl_window *self); #endif /* MGL_WINDOW_H */ |