Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include<GL/freeglut.h>
  2.  
  3. void mouseWheel(int button, int dir, int x, int y)
  4. {
  5.  
  6. printf("in mouse wheel n");
  7.  
  8. if (dir > 0)
  9. {
  10. // Zoom in
  11. ztrans = ztrans - 1.0;
  12. printf("scroll in = %0.3fn ",ztrans);
  13. }
  14. else
  15. {
  16. // Zoom out
  17. ztrans = ztrans + 1.0;
  18. printf("scroll out = %0.3fn ",ztrans);
  19. }
  20.  
  21. glutPostRedisplay();
  22.  
  23. }
  24.  
  25. int main(int argc, char **argv)
  26. {
  27. // general initializations
  28. glutInit(&argc, argv);
  29. glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
  30. glutInitWindowPosition(100, 100);
  31. glutInitWindowSize(800, 400);
  32. glutCreateWindow("Rotation");
  33.  
  34. // register callbacks
  35. glutReshapeFunc(changeSize);
  36. glutDisplayFunc(renderScene);
  37. glutIdleFunc(renderScene);
  38. glutIgnoreKeyRepeat(1);
  39. glutMouseFunc(mouseButton);
  40. glutMotionFunc(mouseMove);
  41. glutMouseWheelFunc(mouseWheel); // Register mouse wheel function
  42.  
  43. glEnable(GL_DEPTH_TEST);
  44.  
  45. glutMainLoop();
  46. return 0;
  47.  
  48. static int k;
  49. static int ztrans
  50. void mouseWheel(int button, int dir, int x, int y)
  51. {
  52.  
  53. k = dir; // int dir is +1 of -1 based on the direction of the wheel motion
  54.  
  55. ztrans = ztrans + k;
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement