Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<gl/glut.h>
- #include<math.h>
- double tx=0,ty=0,tz=0;
- double sx=1,sy=1,sz=1;
- double angle=0.0;
- void myDisplay(){
- glClear(GL_COLOR_BUFFER_BIT);
- int number = 35;
- float radius = 35;
- float twopi = 3.1452423*2;
- glMatrixMode(GL_MODELVIEW);
- glLineStipple(5, 0xAAAA);
- glLoadIdentity();
- glTranslatef(tx,ty,tz);
- glScalef(sx,sy,sz);
- glRotatef(angle,0.0,0.0,1.0);
- gluLookAt(0.0,0.0,100.0, 0.0,0.0,0.0, 0.0,1.0,0.0);
- glBegin(GL_QUADS);
- glColor3f(1.0,1.0,1.0);
- glVertex2f(-40.0, 40.0);
- glVertex2f (40.0, 40.0);
- glVertex2f(40.0, -40.0);
- glVertex2f (-40.0, -40.0);
- glEnd();
- glBegin (GL_LINES);
- glColor3f(1.0,1.0,1.0);
- glVertex2f(150.0, 100.0);
- glVertex2f (-150.0, -100.0);
- glEnd();
- glFlush();
- }
- void pressToClipp (unsigned char press, int x, int y){
- if(press=='c'){
- glBegin (GL_LINES);
- glColor3f(0.1,0.0,0.1);
- glVertex2f(150.0, 100.0);
- glVertex2f (-150.0, -100.0);
- glEnd();
- glFlush();
- }
- }
- void myReshape(int w,int h){
- glViewport(0,0,(GLsizei)w,(GLsizei)h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(60.0,(GLfloat)w/h,1.0,100.0);
- glMatrixMode(GL_MODELVIEW);
- }
- int main(int argc, char *argv[]){
- glutInit( & argc, argv );
- glutCreateWindow("Clipping Algortihm");
- glutDisplayFunc(myDisplay);
- glutKeyboardFunc (pressToClipp);
- glutReshapeFunc(myReshape);
- glutMainLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement