Guest User

Untitled

a guest
Jan 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. void mouse(int button,int state,int x,int y){
  2.  
  3.  
  4.  
  5. if(button==GLUT_LEFT_BUTTON&&state==GLUT_DOWN)
  6. printf("%d,%d\n",x,y);
  7.  
  8.  
  9. if(button==GLUT_LEFT_BUTTON&&state==GLUT_DOWN&&
  10. x>=0&&x<=400&&y>=0&&y<=500){
  11. clicked = true;
  12. dragging = true;
  13. currentX = x;
  14. currentY = y;
  15. glutPostRedisplay();
  16. }
  17. if(button==GLUT_LEFT_BUTTON&&state==GLUT_UP) clicked = false;
  18.  
  19. else if(button==GLUT_LEFT_BUTTON&&state==GLUT_DOWN&&
  20. x>400&&y>=0&&y<=500){
  21. clicked = false;
  22. dragging= false;
  23. }
  24.  
  25. if(button==GLUT_RIGHT_BUTTON){
  26. clicked = false;
  27. glClearColor(0,0,0,0);
  28. }
  29. }
  30.  
  31.  
  32.  
  33. void drag(int x, int y){
  34. if(dragging&&x<=400){
  35. currentX = x;
  36. currentY = y;
  37. glutPostRedisplay();
  38. }
  39. }
Add Comment
Please, Sign In to add comment