From 850a3ac48046e3630524c67ecac5e2f26d499b3f Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 8 Oct 2019 20:55:57 +0200 Subject: Improve mouse monitoring, add 3d view shift support --- ldc_3d_gl_interop.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ldc_3d_gl_interop.py') diff --git a/ldc_3d_gl_interop.py b/ldc_3d_gl_interop.py index a858665..a8f6f8d 100644 --- a/ldc_3d_gl_interop.py +++ b/ldc_3d_gl_interop.py @@ -14,7 +14,7 @@ from OpenGL.GL import shaders from utility.projection import Projection, Rotation from utility.opengl import MomentsVertexBuffer -from utility.mouse import MouseDragMonitor +from utility.mouse import MouseDragMonitor, MouseScrollMonitor lattice_x = 64 lattice_y = 96 @@ -192,10 +192,10 @@ def on_display(): glutSwapBuffers() -mouse_monitor = MouseDragMonitor( - GLUT_LEFT_BUTTON, - drag_callback = lambda dx, dy: rotation.update(0.005*dy, 0.005*dx), - zoom_callback = lambda zoom: projection.update_distance(5*zoom)) +mouse_monitors = [ + MouseDragMonitor(GLUT_LEFT_BUTTON, lambda dx, dy: rotation.update(0.005*dy, 0.005*dx)), + MouseScrollMonitor(lambda zoom: projection.update_distance(5*zoom)) +] def on_timer(t): glutTimerFunc(t, on_timer, t) @@ -203,8 +203,8 @@ def on_timer(t): glutDisplayFunc(on_display) glutReshapeFunc(lambda w, h: projection.update_ratio(w, h)) -glutMouseFunc(mouse_monitor.on_mouse) -glutMotionFunc(mouse_monitor.on_mouse_move) +glutMouseFunc(lambda *args: list(map(lambda m: m.on_mouse(*args), mouse_monitors))) +glutMotionFunc(lambda *args: list(map(lambda m: m.on_mouse_move(*args), mouse_monitors))) glutTimerFunc(10, on_timer, 10) glutMainLoop() -- cgit v1.2.3