aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-21 15:11:04 +0200
committerDavid Robillard <d@drobilla.net>2019-07-21 15:11:26 +0200
commit89d7378adda9987431a665827f92ccbadd893909 (patch)
treeecee4341f8c0b0e02579854884f5e69c1b03ac39
parent29126e6a07eff3cd5ec1636a92bcaa793b98d12a (diff)
Show mouse enter/leave state in pugl_test background
-rw-r--r--pugl_test.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/pugl_test.c b/pugl_test.c
index b5a84e6..9eacf36 100644
--- a/pugl_test.c
+++ b/pugl_test.c
@@ -37,6 +37,7 @@ static double lastMouseX = 0.0;
static double lastMouseY = 0.0;
static float lastDrawTime = 0.0;
static unsigned framesDrawn = 0;
+static bool mouseEntered = false;
static const float cubeVertices[] = {
-1.0f, -1.0f, -1.0f,
@@ -133,6 +134,8 @@ onDisplay(PuglView* view)
glRotatef(xAngle, 0.0f, 1.0f, 0.0f);
glRotatef(yAngle, 1.0f, 0.0f, 0.0f);
+ const float bg = mouseEntered ? 0.2f : 0.0f;
+ glClearColor(bg, bg, bg, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
@@ -218,9 +221,11 @@ onEvent(PuglView* view, const PuglEvent* event)
break;
case PUGL_ENTER_NOTIFY:
fprintf(stderr, "Entered\n");
+ mouseEntered = true;
break;
case PUGL_LEAVE_NOTIFY:
fprintf(stderr, "Exited\n");
+ mouseEntered = false;
break;
case PUGL_FOCUS_IN:
fprintf(stderr, "Focus in\n");