diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/pugl_cairo_demo.c | 14 | ||||
-rw-r--r-- | examples/pugl_embed_demo.c | 21 | ||||
-rw-r--r-- | examples/pugl_gl3_demo.c | 8 | ||||
-rw-r--r-- | examples/pugl_print_events.c | 5 | ||||
-rw-r--r-- | examples/pugl_window_demo.c | 13 |
5 files changed, 30 insertions, 31 deletions
diff --git a/examples/pugl_cairo_demo.c b/examples/pugl_cairo_demo.c index d2e57f8..a1423ae 100644 --- a/examples/pugl_cairo_demo.c +++ b/examples/pugl_cairo_demo.c @@ -203,6 +203,11 @@ onEvent(PuglView* view, const PuglEvent* event) app->entered = false; puglPostRedisplay(view); break; + case PUGL_UPDATE: + if (app->opts.continuous) { + puglPostRedisplay(view); + } + break; case PUGL_EXPOSE: onDisplay(app, view, &event->expose); break; @@ -249,14 +254,9 @@ main(int argc, char** argv) puglShowWindow(view); PuglFpsPrinter fpsPrinter = { puglGetTime(app.world) }; + const double timeout = app.opts.continuous ? (1 / 60.0) : -1.0; while (!app.quit) { - if (app.opts.continuous) { - postButtonRedisplay(view); - } else { - puglPollEvents(app.world, -1); - } - - puglDispatchEvents(app.world); + puglUpdate(app.world, timeout); if (app.opts.continuous) { puglPrintFps(app.world, &fpsPrinter, &app.framesDrawn); diff --git a/examples/pugl_embed_demo.c b/examples/pugl_embed_demo.c index 6bafae5..174fd36 100644 --- a/examples/pugl_embed_demo.c +++ b/examples/pugl_embed_demo.c @@ -1,5 +1,5 @@ /* - Copyright 2012-2019 David Robillard <http://drobilla.net> + Copyright 2012-2020 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -164,6 +164,11 @@ onParentEvent(PuglView* view, const PuglEvent* event) reshapeCube((int)event->configure.width, (int)event->configure.height); puglSetFrame(app->child, getChildFrame(parentFrame)); break; + case PUGL_UPDATE: + if (app->continuous) { + puglPostRedisplay(view); + } + break; case PUGL_EXPOSE: if (puglHasFocus(app->parent)) { glMatrixMode(GL_MODELVIEW); @@ -208,6 +213,11 @@ onEvent(PuglView* view, const PuglEvent* event) case PUGL_CONFIGURE: reshapeCube((int)event->configure.width, (int)event->configure.height); break; + case PUGL_UPDATE: + if (app->continuous) { + puglPostRedisplay(view); + } + break; case PUGL_EXPOSE: onDisplay(view); break; @@ -317,14 +327,7 @@ main(int argc, char** argv) while (!app.quit) { const double thisTime = puglGetTime(app.world); - if (app.continuous) { - puglPostRedisplay(app.parent); - puglPostRedisplay(app.child); - } else { - puglPollEvents(app.world, -1); - } - - puglDispatchEvents(app.world); + puglUpdate(app.world, app.continuous ? 0.0 : -1.0); ++framesDrawn; if (!requestedAttention && thisTime > 5.0) { diff --git a/examples/pugl_gl3_demo.c b/examples/pugl_gl3_demo.c index e0c63ca..26db852 100644 --- a/examples/pugl_gl3_demo.c +++ b/examples/pugl_gl3_demo.c @@ -1,5 +1,5 @@ /* - Copyright 2012-2019 David Robillard <http://drobilla.net> + Copyright 2012-2020 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -177,6 +177,9 @@ onEvent(PuglView* view, const PuglEvent* event) case PUGL_CONFIGURE: onConfigure(view, event->configure.width, event->configure.height); break; + case PUGL_UPDATE: + puglPostRedisplay(view); + break; case PUGL_EXPOSE: onExpose(view); break; case PUGL_CLOSE: app->quit = 1; break; case PUGL_KEY_PRESS: @@ -411,8 +414,7 @@ main(int argc, char** argv) // Grind away, drawing continuously PuglFpsPrinter fpsPrinter = {puglGetTime(app.world)}; while (!app.quit) { - puglPostRedisplay(app.view); - puglDispatchEvents(app.world); + puglUpdate(app.world, 0.0); puglPrintFps(app.world, &fpsPrinter, &app.framesDrawn); } diff --git a/examples/pugl_print_events.c b/examples/pugl_print_events.c index c662117..9c81033 100644 --- a/examples/pugl_print_events.c +++ b/examples/pugl_print_events.c @@ -1,5 +1,5 @@ /* - Copyright 2012-2019 David Robillard <http://drobilla.net> + Copyright 2012-2020 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -68,8 +68,7 @@ main(void) puglShowWindow(app.view); while (!app.quit) { - puglPollEvents(app.world, -1); - puglDispatchEvents(app.world); + puglUpdate(app.world, -1.0); } puglFreeView(app.view); diff --git a/examples/pugl_window_demo.c b/examples/pugl_window_demo.c index 394b959..248d44e 100644 --- a/examples/pugl_window_demo.c +++ b/examples/pugl_window_demo.c @@ -128,6 +128,9 @@ onEvent(PuglView* view, const PuglEvent* event) case PUGL_CONFIGURE: reshapeCube((int)event->configure.width, (int)event->configure.height); break; + case PUGL_UPDATE: + puglPostRedisplay(view); + break; case PUGL_EXPOSE: onDisplay(view); break; @@ -224,15 +227,7 @@ main(int argc, char** argv) PuglFpsPrinter fpsPrinter = {puglGetTime(app.world)}; unsigned framesDrawn = 0; while (!app.quit) { - if (app.continuous) { - for (size_t i = 0; i < 2; ++i) { - puglPostRedisplay(app.cubes[i].view); - } - } else { - puglPollEvents(app.world, -1); - } - - puglDispatchEvents(app.world); + puglUpdate(app.world, app.continuous ? 0.0 : -1.0); ++framesDrawn; if (app.continuous) { |