Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. void processTriangleClicks(GLint x, GLint y) {
  2.    
  3.     static GLintPoint triangleFirstPoint;
  4.     static GLintPoint triangleSecondPoint;
  5.      
  6.      y = gWinHeight - y;     // invert y position
  7.      if (shapeClickCount == 0) {       //first click
  8.          triangleFirstPoint.x = x;
  9.          triangleFirstPoint.y = y;
  10.          shapeClickCount++ ;
  11.      }
  12.      else if (shapeClickCount == 1) {    //second click
  13.          triangleSecondPoint.x = x;
  14.          triangleSecondPoint.y = y;
  15.          printf("First Point: %i %i \n", triangleFirstPoint.x, triangleFirstPoint.y);
  16.          printf("Second Point : %i %i \n", triangleSecondPoint.x, triangleSecondPoint.y);
  17.          shapeClickCount++ ;
  18.     }
  19.     else if (shapeClickCount == 2) {
  20.           shapeClickCount = 0;
  21.           glBegin(GL_TRIANGLES);    // draw line using coords when button last pressed
  22.           glVertex2i(triangleFirstPoint.x, triangleFirstPoint.y);
  23.           glVertex2i(triangleSecondPoint.x, triangleSecondPoint.y);
  24.           glVertex2i(x, y);
  25.           glEnd();
  26.     }
  27.     glFlush();          
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement