diff options
Diffstat (limited to 'src/main/engine/shape/circle.c')
-rw-r--r-- | src/main/engine/shape/circle.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/engine/shape/circle.c b/src/main/engine/shape/circle.c index 9cc79c6..f60e917 100644 --- a/src/main/engine/shape/circle.c +++ b/src/main/engine/shape/circle.c @@ -18,6 +18,8 @@ */ #include <stdlib.h> +#include <GL/gl.h> +#include <math.h> #include "circle.h" Circle * @@ -32,3 +34,18 @@ engine_circle_new(float cx, float cy, float r, int num_segments, int outline) return circle; } + +void +engine_render_circle(Circle *circle) +{ + glBegin(GL_LINE_LOOP); + + for (int i = 0; i < circle->num_segments; i++) { + float theta = 2.0f * M_PI * i / circle->num_segments; + float x = circle->r * cosf(theta); + float y = circle->r * sinf(theta); + glVertex2f(circle->cx + x, circle->cy + y); + } + + glEnd(); +} |