aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-03-09 21:50:00 +0100
committerDavid Robillard <d@drobilla.net>2020-03-09 22:17:44 +0100
commit0444a408dd6667fb69fd6395b9b911bf61d21f76 (patch)
tree34b833941ffd6ea7005b3a783cf7fdbe615f5bc9
parentd949a78a774b7abe274b2d04a92d424a51e0698c (diff)
Window Demo: Fix updating when not runnning continuously
-rw-r--r--examples/cube_view.h2
-rw-r--r--examples/pugl_window_demo.c22
2 files changed, 17 insertions, 7 deletions
diff --git a/examples/cube_view.h b/examples/cube_view.h
index fb32595..82648ac 100644
--- a/examples/cube_view.h
+++ b/examples/cube_view.h
@@ -51,7 +51,7 @@ displayCube(PuglView* const view,
glRotatef((float)xAngle, 0.0f, 1.0f, 0.0f);
glRotatef((float)yAngle, 1.0f, 0.0f, 0.0f);
- const float bg = entered ? 0.2f : 0.1f;
+ const float bg = entered ? 0.2f : 0.0f;
glClearColor(bg, bg, bg, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
diff --git a/examples/pugl_window_demo.c b/examples/pugl_window_demo.c
index a3d87e6..49ceee0 100644
--- a/examples/pugl_window_demo.c
+++ b/examples/pugl_window_demo.c
@@ -108,6 +108,14 @@ onKeyPress(PuglView* view, const PuglEventKey* event)
}
}
+static void
+redisplayView(PuglTestApp* app, PuglView* view)
+{
+ if (!app->continuous) {
+ puglPostRedisplay(view);
+ }
+}
+
static PuglStatus
onEvent(PuglView* view, const PuglEvent* event)
{
@@ -136,21 +144,23 @@ onEvent(PuglView* view, const PuglEvent* event)
cube->yAngle += event->motion.y - cube->lastMouseY;
cube->lastMouseX = event->motion.x;
cube->lastMouseY = event->motion.y;
- if (!app->continuous) {
- puglPostRedisplay(view);
- }
+ redisplayView(app, view);
break;
case PUGL_SCROLL:
cube->dist = fmaxf(10.0f, cube->dist + (float)event->scroll.dy);
- if (!app->continuous) {
- puglPostRedisplay(view);
- }
+ redisplayView(app, view);
break;
case PUGL_ENTER_NOTIFY:
cube->entered = true;
+ redisplayView(app, view);
break;
case PUGL_LEAVE_NOTIFY:
cube->entered = false;
+ redisplayView(app, view);
+ break;
+ case PUGL_FOCUS_IN:
+ case PUGL_FOCUS_OUT:
+ redisplayView(app, view);
break;
default:
break;