diff options
author | David Robillard <d@drobilla.net> | 2019-07-22 17:21:52 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-03 08:32:16 +0200 |
commit | dacaaa5f328ac2598123aa1f0744ddd68c87e9cc (patch) | |
tree | 31bdcb5effdff7d84f946a577cd77d6462dd6083 /test | |
parent | 61476f5de49b20a6836186a82082bc2b7c70e971 (diff) |
Move puglGetTime() to PuglWorld
Diffstat (limited to 'test')
-rw-r--r-- | test/pugl_cairo_test.c | 13 | ||||
-rw-r--r-- | test/pugl_test.c | 8 | ||||
-rw-r--r-- | test/test_utils.h | 8 |
3 files changed, 16 insertions, 13 deletions
diff --git a/test/pugl_cairo_test.c b/test/pugl_cairo_test.c index 3cdf904..7779069 100644 --- a/test/pugl_cairo_test.c +++ b/test/pugl_cairo_test.c @@ -30,6 +30,8 @@ #include <stdio.h> #include <string.h> +static PuglWorld* world = NULL; + static bool continuous = false; static int quit = 0; static bool entered = false; @@ -130,7 +132,7 @@ onDisplay(PuglView* view) // Draw button for (Button* b = buttons; b->label; ++b) { - buttonDraw(cr, b, continuous ? puglGetTime(view) : 0.0); + buttonDraw(cr, b, continuous ? puglGetTime(world) : 0.0); } ++framesDrawn; @@ -202,8 +204,9 @@ main(int argc, char** argv) } } - PuglWorld* world = puglNewWorld(); - PuglView* view = puglNewView(world); + world = puglNewWorld(); + + PuglView* view = puglNewView(world); puglInitWindowClass(view, "PuglCairoTest"); puglInitWindowSize(view, 512, 512); puglInitWindowMinSize(view, 256, 256); @@ -219,7 +222,7 @@ main(int argc, char** argv) puglShowWindow(view); - PuglFpsPrinter fpsPrinter = { puglGetTime(view) }; + PuglFpsPrinter fpsPrinter = { puglGetTime(world) }; while (!quit) { if (continuous) { puglPostRedisplay(view); @@ -230,7 +233,7 @@ main(int argc, char** argv) puglProcessEvents(view); if (continuous) { - puglPrintFps(view, &fpsPrinter, &framesDrawn); + puglPrintFps(world, &fpsPrinter, &framesDrawn); } } diff --git a/test/pugl_test.c b/test/pugl_test.c index b012868..c4df272 100644 --- a/test/pugl_test.c +++ b/test/pugl_test.c @@ -70,7 +70,7 @@ onDisplay(PuglView* view) { PuglTestApp* app = (PuglTestApp*)puglGetHandle(view); - const double thisTime = puglGetTime(view); + const double thisTime = puglGetTime(app->world); if (app->continuous) { const double dTime = thisTime - app->lastDrawTime; app->xAngle = fmodf((float)(app->xAngle + dTime * 100.0f), 360.0f); @@ -204,10 +204,10 @@ main(int argc, char** argv) puglShowWindow(view); - PuglFpsPrinter fpsPrinter = { puglGetTime(view) }; + PuglFpsPrinter fpsPrinter = { puglGetTime(app.world) }; bool requestedAttention = false; while (!app.quit) { - const double thisTime = puglGetTime(view); + const double thisTime = puglGetTime(app.world); if (app.continuous) { puglPostRedisplay(view); @@ -223,7 +223,7 @@ main(int argc, char** argv) } if (app.continuous) { - puglPrintFps(view, &fpsPrinter, &app.framesDrawn); + puglPrintFps(app.world, &fpsPrinter, &app.framesDrawn); } } diff --git a/test/test_utils.h b/test/test_utils.h index 9738d96..12dbfaa 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -148,11 +148,11 @@ printEvent(const PuglEvent* event, const char* prefix) } static inline void -puglPrintFps(PuglView* view, - PuglFpsPrinter* printer, - unsigned* const framesDrawn) +puglPrintFps(const PuglWorld* world, + PuglFpsPrinter* printer, + unsigned* const framesDrawn) { - const double thisTime = puglGetTime(view); + const double thisTime = puglGetTime(world); if (thisTime > printer->lastReportTime + 5) { const double fps = *framesDrawn / (thisTime - printer->lastReportTime); fprintf(stderr, |