opengl not filling in polygon

Viewed 294

I'm trying to draw a filled in circle, but when I draw this, it only shows in wireframe, here is the code I'm using to draw:

void render_circle(Vec2 position, float radius, Vec4 colour) {
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glColor4f(colour.x, colour.y, colour.z, colour.w);

    glBegin(GL_LINE_LOOP);
    int num_segments = 30; //@todo: make this scale for larger radius
    for(int i = 0; i < num_segments; i++) {
        float theta = 2.0f * math_pi * (float)i / (float)num_segments;
        float x = radius * cosf(theta);
        float y = radius * sinf(theta);
        glVertex2f(position.x + x, position.y + y);
    }
    glEnd();
}
1 Answers
Related