aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-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;