SHARE
TWEET

ITS

a guest Apr 21st, 2017 50 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. //INSTRUCTIONS
  5. // for
  6.  
  7.  
  8. double tx=0,ty=0,tz=0;
  9. double sx=1,sy=1,sz=1;
  10. double angle=0.0;
  11. void myDisplay(){
  12.     glClear(GL_COLOR_BUFFER_BIT);
  13.     int number = 35;
  14.     float radius = 35;
  15.     float twopi = 3.1452423*2;
  16.     glMatrixMode(GL_MODELVIEW);
  17.     glLineStipple(5, 0xAAAA);
  18.     //glEnable(GL_LINE_STIPPLE);
  19.     glLoadIdentity();
  20.     glTranslatef(tx,ty,tz);
  21.     glScalef(sx,sy,sz);
  22.     glRotatef(angle,0.0,0.0,1.0);
  23.     gluLookAt(0.0,0.0,100.0, 0.0,0.0,0.0, 0.0,1.0,0.0);
  24.  
  25.         glBegin(GL_QUADS);
  26.     glColor3f(1.0,1.0,1.0);
  27.     glVertex2f(-40.0, 40.0);
  28.     glVertex2f (40.0, 40.0);
  29.     glVertex2f(40.0, -40.0);
  30.     glVertex2f (-40.0, -40.0);
  31.  
  32.         glEnd();
  33.  
  34.  
  35.     /*glBegin(GL_TRIANGLE_FAN);
  36.     glColor3f(0.0, 0.0,1.0);
  37.     glVertex2f(0.0, 0.0);
  38.         for (int i=0; i<40;i++)
  39.             glVertex2f (radius*cosf(i*twopi/number), radius*sinf(i*twopi/34));
  40.         glEnd();
  41.         */
  42.  
  43.  
  44.  
  45.    
  46.  
  47.  
  48.  
  49.         glBegin (GL_LINES);
  50.    
  51.     glColor3f(1.0,1.0,1.0);
  52.     glVertex2f(200.0, 100.0);
  53.     glVertex2f (200.0, -100.0);
  54.     glEnd();
  55.    
  56.         glFlush();
  57.  
  58. }
  59.  
  60. void pressToClipp (unsigned char press, int x, int y){
  61. if(press=='c'){
  62.  
  63.         glBegin (GL_LINES);
  64.    
  65.     glColor3f(0.1,0.0,0.1);
  66.     glVertex2f(150.0, 70.0);
  67.     glVertex2f (-150.0, -70.00);
  68.     glEnd();
  69.    
  70.         glFlush();
  71.  
  72. }
  73.  
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80. void myReshape(int w,int h){
  81.     glViewport(0,0,(GLsizei)w,(GLsizei)h);
  82.     glMatrixMode(GL_PROJECTION);
  83.     glLoadIdentity();
  84.     gluPerspective(60.0,(GLfloat)w/h,1.0,100.0);
  85.     glMatrixMode(GL_MODELVIEW);
  86.  
  87. }
  88. int main(int argc, char *argv[]){
  89.     glutInit( & argc, argv );
  90.     glutCreateWindow("Transformation");
  91.    
  92.     glutDisplayFunc(myDisplay);
  93.     //glutKeyboardFunc(myKeyboard);
  94.     glutKeyboardFunc (pressToClipp);
  95.     glutReshapeFunc(myReshape);
  96.     glutMainLoop();
  97. }
RAW Paste Data
Top