diff options
Diffstat (limited to 'src/main/engine/shape')
-rw-r--r-- | src/main/engine/shape/circle.c | 17 | ||||
-rw-r--r-- | src/main/engine/shape/circle.h | 1 |
2 files changed, 18 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(); +} diff --git a/src/main/engine/shape/circle.h b/src/main/engine/shape/circle.h index f8bb91d..72e69e1 100644 --- a/src/main/engine/shape/circle.h +++ b/src/main/engine/shape/circle.h @@ -29,5 +29,6 @@ typedef struct { } Circle; Circle *engine_circle_new(float cx, float cy, float r, int num_segments, int outline); +void engine_render_circle(Circle *circle); #endif /* __CIRCLE_H__ */ |