Professional Documents
Culture Documents
Circle Assignment
Circle Assignment
h>
int x1=0, y1=0, d=0,ct=0; constintscreenWidth = 640; constintscreenHeight = 480; constintbotm = 50; constint left = 50; constint top = 480-50; constint right = 640-50;
voidinit ( void ){ glClearColor(1.0,1.0,1.0,0.0); glColor3f(0.0f, 0.0f, 0.0f); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, (GLdouble)screenWidth, 0.0, (GLdouble)screenHeight); }
glVertex2i(x1+x, y1+y); glVertex2i(y1+x,x1+y); glVertex2i(y1+x,-x1+y); glVertex2i(x1+x,-y1+y); glVertex2i(-x1+x,-y1+y); glVertex2i(-y1+x,-x1+y); glVertex2i(-y1+x,x1+y); glVertex2i(-x1+x,y1+y); while(y1>x1) { if(d<0) d=d+(2*x1)+3; else { d=d+((2*x1)-(2*y1))+5; y1--; } x1++; glVertex2i(x1+x, y1+y); glVertex2i(y1+x,x1+y); glVertex2i(y1+x,-x1+y); glVertex2i(x1+x,-y1+y); glVertex2i(-x1+x,-y1+y); glVertex2i(-y1+x,-x1+y); glVertex2i(-y1+x,x1+y);
glVertex2i(-x1+x,y1+y); } glEnd(); }
if (x >= 590) x = 590 - 1; if (y <= 50) y = 50 + 1; if (x <= 50) x = 50 + 1; if (y >= 430) y = 430 + 1;
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN &&ct==0){ glBegin(GL_POINTS); glVertex2i(x, (screenHeight-y) ); x1=x; y1=y; glEnd(); ct++; }
x1=x; y1=y; }
int main ( intargc, char** argv ){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(640,480); glutInitWindowPosition(100, 150); glutCreateWindow ( argv[0] );
Output: