From e83c2b421d140244a6b9edb051b3e0d4aacda332 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 22 Jul 2019 16:30:53 +0200 Subject: Add PuglWorld The old API was broken for programs that manage multiple views, since it was impossible to wait for events on any view. There are also several functions in the API which are not actually associated with views at all, so those can now be moved to the more appropriate PuglWorld to make this more clear. The old puglInit() and puglDestroy() functions are preserved for compatibility, but marked as deprecated. --- test/pugl_cairo_test.c | 6 ++++-- test/pugl_test.c | 29 +++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/pugl_cairo_test.c b/test/pugl_cairo_test.c index a16c821..3cdf904 100644 --- a/test/pugl_cairo_test.c +++ b/test/pugl_cairo_test.c @@ -202,7 +202,8 @@ main(int argc, char** argv) } } - PuglView* view = puglInit(NULL, NULL); + PuglWorld* world = puglNewWorld(); + PuglView* view = puglNewView(world); puglInitWindowClass(view, "PuglCairoTest"); puglInitWindowSize(view, 512, 512); puglInitWindowMinSize(view, 256, 256); @@ -233,6 +234,7 @@ main(int argc, char** argv) } } - puglDestroy(view); + puglFreeView(view); + puglFreeWorld(world); return 0; } diff --git a/test/pugl_test.c b/test/pugl_test.c index b8a0a42..b012868 100644 --- a/test/pugl_test.c +++ b/test/pugl_test.c @@ -34,16 +34,17 @@ typedef struct { - bool continuous; - int quit; - float xAngle; - float yAngle; - float dist; - double lastMouseX; - double lastMouseY; - double lastDrawTime; - unsigned framesDrawn; - bool mouseEntered; + PuglWorld* world; + bool continuous; + int quit; + float xAngle; + float yAngle; + float dist; + double lastMouseX; + double lastMouseY; + double lastDrawTime; + unsigned framesDrawn; + bool mouseEntered; } PuglTestApp; static void @@ -178,7 +179,9 @@ main(int argc, char** argv) } } - PuglView* view = puglInit(NULL, NULL); + app.world = puglNewWorld(); + + PuglView* view = puglNewView(app.world); puglInitWindowClass(view, "PuglTest"); puglInitWindowSize(view, 512, 512); puglInitWindowMinSize(view, 256, 256); @@ -224,6 +227,8 @@ main(int argc, char** argv) } } - puglDestroy(view); + puglFreeView(view); + puglFreeWorld(app.world); + return 0; } -- cgit v1.2.1