I’m trying to draw a Circle that will be filled using GL_LINES.

Im able to draw a Circle using sin and cos but that doesn’t fill it, only give me a frame.

I had an idea to draw just a bunch of horizontal lines (enough to make a cricle), but I wasn’t sure how to approach this. (Trying to make a gradient as well). Here’s what I have for the circle the way it is now.

```
typedef struct
{
float x;
float y;
}CIRCLE;
CIRCLE circle;
void createcircle (int k, int r, int h) {
glBegin(GL_LINES);
for (int i = 0; i < 180; i++)
{
circle.x = r * cos(i) - h;
circle.y = r * sin(i) + k;
glVertex3f(circle.x + k,circle.y - h,0);
circle.x = r * cos(i + 0.1) - h;
circle.y = r * sin(i + 0.1) + k;
glVertex3f(circle.x + k,circle.y - h,0);
}
glEnd();
}
```

try GL_POLYGON instead of GL_LINES

I had an idea to draw just a bunch of horizontal lines (enough to make a cricle), but I wasn’t sure how to approach this.

how about this:

- calculate the next y-coordinate: y = (r^2 - x^2)^(1/2)
- do this in a for loop: start: y = -r; end: y = r; step: y += r/10 (for 10 horizontal lines)
- you have y, now calculate x tha same way: x = (r^2 - y^2)^(1/2)
- create 2 vertices: (-x|y) and (x|y)

Hello, you can also use GL_TRIANGLE_FAN to draw a circle. This is the code:

```
void drawCircle(float r, float x, float y) {
float i = 0.0f;
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x, y); // Center
for(i = 0.0f; i <= 360; i++)
glVertex2f(r*cos(M_PI * i / 180.0) + x, r*sin(M_PI * i / 180.0) + y);
glEnd();
}
```

It is possible, but why would you draw a circle that way? To later make a scanline noise effect or something?

It is easier to:

- Draw a polygon approximation.
- Draw a GL_POINT and discard fragments by distance from the center.