diff options
author | 2025-05-16 09:31:05 +0200 | |
---|---|---|
committer | 2025-05-16 09:31:05 +0200 | |
commit | 084547f8a9176f558eb75a956bc248800274d4c4 (patch) | |
tree | eae125650ad3c3f4481a425e1b929f66d32a6ca7 /src/main/ui/x11/ui.c | |
parent | d2a5ac68cc98599cee9b358628f603723fd0e041 (diff) | |
download | tris-084547f8a9176f558eb75a956bc248800274d4c4.tar.gz tris-084547f8a9176f558eb75a956bc248800274d4c4.zip |
Add event function ui_on_expose
Diffstat (limited to 'src/main/ui/x11/ui.c')
-rw-r--r-- | src/main/ui/x11/ui.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/ui/x11/ui.c b/src/main/ui/x11/ui.c index 591c90e..8e5ce45 100644 --- a/src/main/ui/x11/ui.c +++ b/src/main/ui/x11/ui.c @@ -99,16 +99,21 @@ ui_init() glXMakeCurrent(display, window, gl_context); } +static void +ui_on_expose(XEvent event, void (*draw_frame)()) +{ + if (event.type != Expose) return; + draw_frame(); + glXSwapBuffers(display, window); +} + void ui_loop(void (*draw_frame)()) { XEvent event; while (1) { XNextEvent(display, &event); - if (event.type == Expose) { - draw_frame(); - glXSwapBuffers(display, window); - } + ui_on_expose(event, draw_frame); if (event.type == KeyPress) { break; } |