Advertisement
Guest User

Orxan

a guest
Apr 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include<gl/glut.h>
  2. #include<math.h>
  3.  
  4. double tx=0,ty=0,tz=0;
  5. double sx=1,sy=1,sz=1;
  6. double angle=0.0;
  7. void myDisplay(){
  8. glClear(GL_COLOR_BUFFER_BIT);
  9. int number = 35;
  10. float radius = 35;
  11. float twopi = 3.1452423*2;
  12. glMatrixMode(GL_MODELVIEW);
  13. glLineStipple(5, 0xAAAA);
  14.  
  15. glLoadIdentity();
  16. glTranslatef(tx,ty,tz);
  17. glScalef(sx,sy,sz);
  18. glRotatef(angle,0.0,0.0,1.0);
  19. gluLookAt(0.0,0.0,100.0, 0.0,0.0,0.0, 0.0,1.0,0.0);
  20.  
  21. glBegin(GL_QUADS);
  22. glColor3f(1.0,1.0,1.0);
  23. glVertex2f(-40.0, 40.0);
  24. glVertex2f (40.0, 40.0);
  25. glVertex2f(40.0, -40.0);
  26. glVertex2f (-40.0, -40.0);
  27. glEnd();
  28. glBegin (GL_LINES);
  29.  
  30. glColor3f(0.0,1.0,0.0);
  31. glVertex2f(200.0, 100.0);
  32. glVertex2f (200.0, -100.0);
  33. glEnd();
  34.  
  35. glFlush();
  36.  
  37. }
  38.  
  39. void pressToClipp (unsigned char press, int x, int y){
  40. if(press=='c'){
  41.  
  42. glBegin (GL_LINES);
  43. glColor3f(0.0,1.0,0.1);
  44. glVertex2f(150.0, 70.0);
  45. glVertex2f (-150.0, -70.00);
  46. glEnd();
  47. glFlush();
  48. }
  49.  
  50. }
  51.  
  52. void myReshape(int w,int h){
  53. glViewport(0,0,(GLsizei)w,(GLsizei)h);
  54. glMatrixMode(GL_PROJECTION);
  55. glLoadIdentity();
  56. gluPerspective(60.0,(GLfloat)w/h,1.0,100.0);
  57. glMatrixMode(GL_MODELVIEW);
  58.  
  59. }
  60. int main(int argc, char *argv[]){
  61. glutInit( & argc, argv );
  62. glutCreateWindow("Clipping Algortihm");
  63.  
  64. glutDisplayFunc(myDisplay);
  65. glutKeyboardFunc (pressToClipp);
  66. glutReshapeFunc(myReshape);
  67. glutMainLoop();
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement