Mesa (master): progs/glsl: improve the mouse drag/rotate code a little

Brian Paul brianp at kemper.freedesktop.org
Mon Mar 29 17:47:52 UTC 2010


Module: Mesa
Branch: master
Commit: 909f0b356eab04f03389ea36ebf0a83dbb930f5d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=909f0b356eab04f03389ea36ebf0a83dbb930f5d

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Mar 29 11:44:39 2010 -0600

progs/glsl: improve the mouse drag/rotate code a little

---

 progs/glsl/fsraytrace.c |    8 +++-----
 progs/glsl/vsraytrace.c |   10 ++++------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c
index 357da67..392f01b 100644
--- a/progs/glsl/fsraytrace.c
+++ b/progs/glsl/fsraytrace.c
@@ -333,6 +333,7 @@ drag(int x, int y)
     yRot = (float)(y - WinHeight/2) / scale;
     identity(rot);
     rotate_xy(rot, yRot, xRot);
+    glutPostRedisplay();
   }
 }
 
@@ -341,10 +342,7 @@ static
 void
 mouse(int button, int state, int x, int y)
 {
-  if(state == GLUT_DOWN)
-  {
-    mouseGrabbed = !mouseGrabbed;
-  }
+  mouseGrabbed = (state == GLUT_DOWN);
 }
 
 
@@ -398,7 +396,7 @@ main(int argc, char *argv[])
   glutKeyboardFunc(Key);
   glutDisplayFunc(Draw);
   glutMouseFunc(mouse);
-  glutPassiveMotionFunc(drag);
+  glutMotionFunc(drag);
   glutIdleFunc(Draw);
   Init();
   glutMainLoop();
diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c
index 327d48b..ee4fe47 100644
--- a/progs/glsl/vsraytrace.c
+++ b/progs/glsl/vsraytrace.c
@@ -31,7 +31,7 @@
 
 static int Win;
 static int WinWidth = 256, WinHeight = 256;
-static int mouseGrabbed = 0;
+static GLboolean mouseGrabbed = GL_FALSE;
 static GLuint vertShader;
 static GLuint program;
 float rot[9] = {1,0,0,  0,1,0,   0,0,1};
@@ -323,6 +323,7 @@ drag(int x, int y)
     yRot = (float)(y - WinHeight/2) / scale;
     identity(rot);
     rotate_xy(rot, yRot, xRot);
+    glutPostRedisplay();
   }
 }
 
@@ -331,10 +332,7 @@ static
 void
 mouse(int button, int state, int x, int y)
 {
-  if(state == GLUT_DOWN)
-  {
-    mouseGrabbed = !mouseGrabbed;
-  }
+  mouseGrabbed = (state == GLUT_DOWN);
 }
 
 
@@ -388,7 +386,7 @@ main(int argc, char *argv[])
   glutDisplayFunc(Draw);
   glutIdleFunc(Draw);
   glutMouseFunc(mouse);
-  glutPassiveMotionFunc(drag);
+  glutMotionFunc(drag);
   Init();
   glutMainLoop();
   return 0;




More information about the mesa-commit mailing list