DiRNiS
August 30th, 2009, 01:40 AM
Hi all, I am trying to draw a simple circle using OpenGL and C++
I am just getting started coding OpenGL.
I got the following code to draw the circle:
void drawCircle(float cx, float cy, float r, int num_segments)
{
glBegin(GL_LINE_LOOP);
for(int ii = 0; ii < num_segments; ii++)
{
float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
float x = r * cosf(theta);//calculate the x component
float y = r * sinf(theta);//calculate the y component
glVertex2f(x + cx, y + cy);//output vertex
}
glEnd();
}
Now in a separate function I am trying to call the drawCircle functions as follows in order to get the circle to appear:
glColor3f(0.0,0.0,0.0);
drawCircle(0,0,10,50);
However, I see no circle. Could somebody point me in the right direction of what I am doing wrong? Thanks!
I am just getting started coding OpenGL.
I got the following code to draw the circle:
void drawCircle(float cx, float cy, float r, int num_segments)
{
glBegin(GL_LINE_LOOP);
for(int ii = 0; ii < num_segments; ii++)
{
float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
float x = r * cosf(theta);//calculate the x component
float y = r * sinf(theta);//calculate the y component
glVertex2f(x + cx, y + cy);//output vertex
}
glEnd();
}
Now in a separate function I am trying to call the drawCircle functions as follows in order to get the circle to appear:
glColor3f(0.0,0.0,0.0);
drawCircle(0,0,10,50);
However, I see no circle. Could somebody point me in the right direction of what I am doing wrong? Thanks!