daily pastebin goal
14%
SHARE
TWEET

Orxan

a guest Apr 21st, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  29.         glBegin (GL_LINES);
  30.             glColor3f(1.0,1.0,1.0);
  31.             glVertex2f(150.0, 100.0);
  32.             glVertex2f (-150.0, -100.0);
  33.             glEnd();
  34.         glFlush();
  35.  
  36. }
  37.  
  38. void pressToClipp (unsigned char press, int x, int y){
  39. if(press=='c'){
  40.  
  41.     glBegin (GL_LINES);
  42.             glColor3f(0.1,0.0,0.1);
  43.             glVertex2f(150.0, 100.0);
  44.             glVertex2f (-150.0, -100.0);
  45.             glEnd();
  46.     glFlush();
  47.     }
  48.  
  49. }
  50.  
  51. void myReshape(int w,int h){
  52.     glViewport(0,0,(GLsizei)w,(GLsizei)h);
  53.     glMatrixMode(GL_PROJECTION);
  54.     glLoadIdentity();
  55.     gluPerspective(60.0,(GLfloat)w/h,1.0,100.0);
  56.     glMatrixMode(GL_MODELVIEW);
  57.  
  58. }
  59. int main(int argc, char *argv[]){
  60.     glutInit( & argc, argv );
  61.     glutCreateWindow("Clipping Algortihm");
  62.    
  63.     glutDisplayFunc(myDisplay);
  64.     glutKeyboardFunc (pressToClipp);
  65.     glutReshapeFunc(myReshape);
  66.     glutMainLoop();
  67. }
RAW Paste Data
Top