summaryrefslogtreecommitdiff
path: root/pugl_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-29 06:08:19 +0000
committerDavid Robillard <d@drobilla.net>2012-04-29 06:08:19 +0000
commitd4b2829de83ca5f0efd3d1ee2683ee400e63ffe2 (patch)
treed2e514e1090cf34e77174503bfb4859e9448fdb8 /pugl_test.c
parent48c439c06576092e1b3de89146c7f201a3f4453b (diff)
Scroll API.
Diffstat (limited to 'pugl_test.c')
-rw-r--r--pugl_test.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/pugl_test.c b/pugl_test.c
index 03afac0..57b9e5e 100644
--- a/pugl_test.c
+++ b/pugl_test.c
@@ -34,6 +34,7 @@
static int quit = 0;
static float xAngle = 0.0f;
static float yAngle = 0.0f;
+static float dist = 10.0f;
#define KEY_ESCAPE 27
@@ -43,7 +44,7 @@ onDisplay(PuglWindow* win)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
- glTranslatef(0.0f, 0.0f, -10.0f);
+ glTranslatef(0.0f, 0.0f, dist * -1);
glRotatef(xAngle, 0.0f, 1.0f, 0.0f);
glRotatef(yAngle, 1.0f, 0.0f, 0.0f);
@@ -102,13 +103,21 @@ onMotion(PuglWindow* win, int x, int y)
}
static void
-onMouse(PuglWindow* handle, int button, bool press, int x, int y)
+onMouse(PuglWindow* win, int button, bool press, int x, int y)
{
fprintf(stderr, "Mouse %d %s at %d,%d\n",
button, press ? "down" : "up", x, y);
}
static void
+onScroll(PuglWindow* win, int dx, int dy)
+{
+ fprintf(stderr, "Scroll %d %d\n", dx, dy);
+ dist += dy / 4.0f;
+ puglPostRedisplay(win);
+}
+
+static void
onClose(PuglWindow* win)
{
quit = 1;
@@ -122,6 +131,7 @@ main(int argc, char** argv)
puglSetKeyboardFunc(win, onKeyboard);
puglSetMotionFunc(win, onMotion);
puglSetMouseFunc(win, onMouse);
+ puglSetScrollFunc(win, onScroll);
puglSetDisplayFunc(win, onDisplay);
puglSetCloseFunc(win, onClose);