Block for events in main thread, and avoid burning the planet

This commit is contained in:
Martin Fouilleul 2023-06-26 20:00:29 +02:00
parent 0a83f26f7b
commit b7e3e83f3e
2 changed files with 10 additions and 6 deletions

@ -1 +1 @@
Subproject commit ffb900d872a456cc5e7cc1762b1846c0c4df08cd
Subproject commit 21aa1bef68c3590c1898a539da4c38e3854a5a9d

View File

@ -767,7 +767,7 @@ int main(int argc, char** argv)
//WARN: this is a workaround to avoid stalling the first few times we acquire drawables from
// the surfaces... This should probably be fixed in the implementation of mtl_surface!
//*
for(int i=0; i<3; i++)
{
mg_surface_prepare(app->surface);
@ -780,7 +780,7 @@ int main(int argc, char** argv)
mg_render(app->debugOverlay.surface, app->debugOverlay.canvas);
mg_surface_present(app->debugOverlay.surface);
}
//*/
ui_init(&app->debugOverlay.ui);
//NOTE: show window and start runloop
@ -793,15 +793,19 @@ int main(int argc, char** argv)
while(!mp_should_quit())
{
mp_pump_events(0);
mp_pump_events(-1);
//TODO: what to do with mem scratch here?
}
void* res;
pthread_join(runloopThread, &res);
// mg_canvas_destroy(app->canvas);
// mg_surface_destroy(app->surface);
mg_canvas_destroy(app->canvas);
mg_surface_destroy(app->surface);
mg_canvas_destroy(app->debugOverlay.canvas);
mg_surface_destroy(app->debugOverlay.surface);
mp_window_destroy(app->window);
mp_terminate();