// C program to demonstrate // drawing a circle using // OpenGL #include #include #include #define pi 3.142857 void myInit (void) { // making background color black as first // 3 arguments all are 0.0 glClearColor(0.0, 0.0, 0.0, 1.0); // making picture color green (in RGB mode), as middle argument is 1.0 glColor3f(1.0, 1.0, 1.0); // breadth of picture boundary is 1 pixel glPointSize(1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // setting window dimension in X- and Y- direction gluOrtho2D(-420, 420, -420, 420); } void display (void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); float x, y, i; float e, w, f; float a, b, c; float d; printf("input number of twists in mobius?"); scanf(" %f",&e); a=a*pi/180; // iterate y up to 2*pi, i.e., 360 degree // with small increment in angle as // glVertex2i just draws a point on specified co-ordinate // let 200 is radius of circle and as, // circle is defined as x=r*cos(i) and y=r*sin(i) w = e / 2; for ( x = -3.1426; x < pi; x += 0.001) { y = (((cos(w * x)) / 2) - ((sin(w * x)) / 1)); a = 300 * (cos(x)); b = (300 * (sin(y))) * 1; for ( c = .5; c < 1; c += 0.07) { d=b*c; glVertex2i(a, d); } } glEnd(); glFlush(); } int main (int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // giving window size in X- and Y- direction glutInitWindowSize(500, 500); glutInitWindowPosition(0, 0); // Giving name to window glutCreateWindow("Mobius Drawing"); myInit(); glutDisplayFunc(display); glutMainLoop(); }