#include #include #include #include #include #include //FILE TOPEN & DRAW THE FIGURE float x1,y1,x2,y2; int sw=500,sh=400; char *name; int count=0; float ang=0,angle; void lineTo() { glBegin(GL_LINES); glVertex2f((GLfloat)x1,(GLfloat)y1); glVertex2f((GLfloat)x2,(GLfloat)y2); glEnd(); glFlush(); } void myInit() { glClearColor(0.0f,1.0f,1.0f,1.0f); // background is white glColor3f(0.0f,0.0f,0.0f); // set color of stuff glLoadIdentity(); glMatrixMode(GL_PROJECTION); gluOrtho2D(0,1,0,1); // gluOrtho2D(0,(GLdouble)sw,0,(GLdouble)sh,-1,1); // glMatrixMode(GL_MODELVIEW); glViewport(0,0,sw,sh); } void display() { FILE *in; int i,j ,points,lines,ct=0; char ch; //,name[20]; //cout<<"Enter file name\n"; //cin>>name; glClear(GL_COLOR_BUFFER_BIT); // clear screen // glMatrixMode(GL_MODELVIEW); // set up rotation glRotatef(angle,1,1,0); if((in=fopen(name,"r"))==NULL) printf("\nERROR;-"); else { while((ch=(char)fgetc(in))!='*'); //to read till **** while((ch=(char)fgetc(in))!='\n'); //reading **** fscanf(in,"%f %f %f %f",&x1,&y1,&x2,&y2); //pts. not used fscanf(in,"%d",&lines); //total no. of lines for(i=0;icount) goto outside; } } } outside: fclose(in); glLoadIdentity(); glutSwapBuffers(); } void myKeys(unsigned char key,int x,int y) { switch(key) { case 'a':count=count+5;break; case 's':count=count-5;break; case 'r':ang +=1.0;break; case 't':ang -=1.0;break; } display(); } void spinner(void) { angle +=ang; display(); } void main(int argv,char **argc) { cout<<"Enter integer\n"; cin>>count; name=argc[1]; glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(sw,sh); glutInitWindowPosition(00,00); glutCreateWindow("IT'S GRAPHIC WINDOW BY -:NILESH:-"); // myInit(); // glutFullScreen(); glutKeyboardFunc(myKeys); glutDisplayFunc(display); glutIdleFunc(spinner); myInit(); glutMainLoop(); }