-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawCircle.txt
52 lines (45 loc) · 1.04 KB
/
DrawCircle.txt
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
void DrawCircle()
{
float cx;
float cy;
float r;
int num_segments = 500;
glClear(GL_COLOR_BUFFER_BIT);
for (size_t i = 0; i < 50; i++)
{
R = (random2(100) / 100.0);
G = (random2(100) / 100.0);
B = (random2(100) / 100.0);
float cx = rand() % 640;
float cy = rand() % 480;
float r = rand() % 80;
glBegin(GL_POINTS);
glColor3f(R, G, B);
for (float ii = 0; ii < num_segments; ii += .5)
{
GLfloat angle = ii * 0.0174533;
glVertex2d(cx + (cos(angle) * r), cy + (sin(angle) * r));
}
glEnd();
glFlush();
}
for (size_t i = 0; i < 50; i++)
{
R = (random2(100) / 100.0);
G = (random2(100) / 100.0);
B = (random2(100) / 100.0);
float cx = rand() % 640;
float cy = rand() % 480;
float r = rand() % 80;
glBegin(GL_LINE_LOOP);
glColor3f(R, G, B);
for (float ii = 0; ii < num_segments; ii += .5)
{
GLfloat angle = ii * 0.0174533;
glVertex2f(cx, cy);//output vertex
glVertex2d(cx + (cos(angle) * r), cy + (sin(angle) * r));
}
glEnd();
glFlush();
}
}