Draw Circle in OpenGL

glColor3f(0.92,0.93,0.38); // (R,G,B)
glBegin(GL_TRIANGLE_FAN);
for(int ii = 0; ii < 300; ii++)
{
float cx = 35; //X coordinate
float cy = 250; //y coordinate
float r = 30.0; //radius
float theta = 2.0f * 3.1415926f * float(ii) / float(300);//get the current angle
float x = (r-45) * cosf(theta);//calculate the x component
float y = r * sinf(theta);//calculate the y component
glVertex2f(x + cx, y + cy);//output vertex
}
glEnd();

Comments

Popular posts from this blog

OPENGL COLOR CODES

OpenGL Texture