0% found this document useful (0 votes)
7 views2 pages

CG 4 Thprogram

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

CG 4 Thprogram

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

//Atharva Pashilkar SE-A COMPS-59

#include <GL/glut.h>

#include <stdio.h>

Int xc, yc, r;

Void plot(int x, int y) {

glBegin(GL_POINTS);

glVertex2i(x + xc, y + yc);

glVertex2i(x + xc, -y + yc);

glVertex2i(-x + xc, -y + yc);

glVertex2i(-x + xc, y + yc);

glVertex2i(y + xc, x + yc);

glVertex2i(-y + xc, x + yc);

glVertex2i(-y + xc, -x + yc);

glVertex2i(y + xc, -x + yc);

glEnd();

Void midpointCircle() {

Int x = 0;

Int y = r;

Int d = 1 – r;

Plot(x, y);

While (x < y) {

If (d < 0) {

D += 2 * x + 3;

} else {

D += 2 * (x – y) + 5;

y--;

X++;
Plot(x, y);

glFlush();

Void display() {

glClear(GL_COLOR_BUFFER_BIT);

midpointCircle();

Void init() {

glClearColor(1.0, 1.0, 1.0, 1.0);

glColor3f(0.0, 0.0, 0.0);

glPointSize(1.0);

gluOrtho2D(-500, 500, -500, 500);

Int main(int argc, char** argv) {

Printf(“Enter the coordinates of the center:\n”);

Scanf(“%d %d”, &xc, &yc);

Printf(“Enter the radius:\n”);

Scanf(“%d”, &r);

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

glutInitWindowSize(500, 500);

glutInitWindowPosition(0, 0);

glutCreateWindow(“Midpoint Circle Algorithm”);

init();

glutDisplayFunc(display);

glutMainLoop();

return 0;

You might also like