anthony1777

07-20-2016, 01:23 PM

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();

}

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();

}