aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-19 22:12:52 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-19 22:12:52 +0200
commit9da3c2188060dc982412d7a6e1cd2051b9ddb6a6 (patch)
tree18d7cd9ec63c1f2e42dcda3941907f32e34ac241 /tests
parent3bdf82eec2c915e91ae487e29d72639f9efcad67 (diff)
Change from callback to window poll
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/main.c b/tests/main.c
index 38a0931..e7dc656 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <mgl/mgl.h>
#include <mgl/window/window.h>
+#include <mgl/window/event.h>
#include <mgl/graphics/texture.h>
#include <mgl/graphics/rectangle.h>
#include <mgl/graphics/sprite.h>
@@ -45,12 +46,8 @@ int main(int argc, char **argv) {
userdata.texture = &texture;
userdata.font = &font;
- mgl_window_callback window_callback;
- window_callback.userdata = &userdata;
- window_callback.draw = draw;
-
mgl_window window;
- if(mgl_window_create(&window, "mgl", 1280, 720, &window_callback) != 0)
+ if(mgl_window_create(&window, "mgl", 1280, 720) != 0)
return 1;
if(mgl_texture_load_from_file(&texture, "tests/X11.png", NULL) != 0)
@@ -59,9 +56,15 @@ int main(int argc, char **argv) {
if(mgl_font_load_from_file(&font, "/usr/share/fonts/noto/NotoSans-Regular.ttf", 32) != 0)
return 1;
+ mgl_event event;
for(;;) {
- mgl_window_events_poll(&window);
- mgl_window_draw(&window);
+ while(mgl_window_events_poll(&window, &event)) {
+
+ }
+
+ mgl_window_clear(&window, (mgl_color){0, 0, 0, 255});
+ draw(&window, &userdata);
+ mgl_window_display(&window);
}
mgl_font_unload(&font);