-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9. Circle_mid_pts.cpp
64 lines (58 loc) · 1.09 KB
/
9. Circle_mid_pts.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "./freeglut-3.2.1/include/GL/freeglut.h"
#include<iostream>
#include<math.h>
using namespace std;
void circle()
{
glColor3f(1.0, 0.0, 0.0);
glPointSize(2.0);
float r = 100;
float x = 0, y = r;
float p = 1-r;
glBegin(GL_POINTS);
while(x!=y)
{
x = x+1;
if(p<0)
{
p = p+ 2*x +3;
}
else
{
y = y-1;
p = p+2*x-2*y+5;
}
glVertex2i(x, y);
glVertex2i(y, x);
glVertex2i(y, -x);
glVertex2i(x, -y);
glVertex2i(-x, y);
glVertex2i(-y, x);
glVertex2i(-y, -x);
glVertex2i(-x, -y);
}
glEnd();
glFlush();
}
void init()
{
glClearColor(1.0,1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
glViewport(0, 0, 640, 480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-250, 250, -250, 250);
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(100, 100);
glutInitWindowSize(500, 500);
glutCreateWindow("Circle_Display");
init();
glutDisplayFunc(circle);
glutMainLoop();
return 0;
}