Advertisement
Shishu

mouse motion in visual basic

Apr 12th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GL/glut.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. float winWid,winHeight;
  7. float rx=0,ry=0,r=1,g=1,b=1;
  8. float rotAngle =5;
  9.  
  10. void display( void )
  11. {
  12.     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  13.     glColor3f(r,g,b);
  14.     glRectf(rx,ry,50+rx,50+ry);
  15.     glutSwapBuffers();
  16.  
  17.  
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. void motion(int x, int y)
  27. {
  28.     rx=x;
  29.     ry=winHeight-y;
  30.  
  31.     if(rx<300 && ry<200)
  32.     {
  33.         r=1;
  34.         g=0;
  35.         b=0;
  36.     }
  37.    
  38.     if(rx>300 && ry>200)
  39.     {
  40.         r=0;
  41.         g=1;
  42.         b=1;
  43.     }
  44.  
  45.    
  46.     if(rx<300 && ry>200)
  47.     {
  48.         r=0;
  49.         g=0;
  50.         b=1;
  51.     }
  52.    
  53.     if(rx>300 && ry<200)
  54.     {
  55.         r=1;
  56.         g=0;
  57.         b=1;
  58.     }
  59. }
  60.  
  61.  
  62.  
  63. void passivemotion(int x, int y)
  64.  
  65. {
  66.  
  67.     rx=x;
  68.     ry=winHeight-y;
  69.  
  70.     if(rx<300 && ry<200)
  71.     {
  72.         r=1;
  73.         g=0;
  74.         b=0;
  75.     }
  76.    
  77.     if(rx>300 && ry>200)
  78.     {
  79.         r=0;
  80.         g=1;
  81.         b=1;
  82.     }
  83.  
  84.    
  85.     if(rx<300 && ry>200)
  86.     {
  87.         r=0;
  88.         g=0;
  89.         b=1;
  90.     }
  91.    
  92.     if(rx>300 && ry<200)
  93.     {
  94.         r=1;
  95.         g=0;
  96.         b=1;
  97.     }
  98.  
  99. }
  100.  
  101. void mousebutton(int button, int state, int x, int y)
  102. {
  103.     if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
  104.  
  105.     {
  106.         rx = x; ry = winHeight - y;
  107.        
  108.     }
  109. }
  110.  
  111.  
  112.  
  113. int main(int argc, char *argv[])
  114. {
  115.     winWid = 600.0;
  116.     winHeight = 400.0;
  117.  
  118.     glutInit(&argc, argv);
  119.     glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
  120.     glutCreateWindow("Basic example");
  121.     glutPositionWindow(200,200);
  122.     glutReshapeWindow(winWid,winHeight);
  123.     glutReshapeWindow(600,400);
  124.  
  125.     glClearColor(0.0,0.0,0.0,1.0);
  126.  
  127.     glMatrixMode(GL_PROJECTION);
  128.     glLoadIdentity();
  129.     glOrtho(0.0,winWid,0.0,winHeight, -100.0, 100.0);
  130.  
  131.     glMatrixMode(GL_MODELVIEW);
  132.     glLoadIdentity();
  133.     glutDisplayFunc(display);
  134.     glutIdleFunc(display);
  135.     //glutMotionFunc(motion);
  136.     //glutPassiveMotionFunc(passivemotion);
  137.     //glutMouseFunc( mousebutton);
  138.    
  139.     glutMainLoop();
  140.  
  141.     return 0;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement