From 9da3c2188060dc982412d7a6e1cd2051b9ddb6a6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 19 Oct 2021 22:12:52 +0200 Subject: Change from callback to window poll --- tests/main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests') 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 #include #include +#include #include #include #include @@ -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); -- cgit v1.2.3