diff options
Diffstat (limited to 'src/main/engine/engine.c')
-rw-r--r-- | src/main/engine/engine.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index d66c242..048c618 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <time.h> #include <GL/gl.h> +#include <math.h> #include "engine.h" #include "../util.h" #include "ui/ui.h" @@ -157,6 +158,32 @@ draw_lines() } static void +render_circle(Circle *circle) +{ + 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); + } +} + +static void +draw_circles() +{ + if (engine == NULL || engine->circles == NULL || engine->circles->size <= 0) return; + glBegin(GL_LINE_LOOP); + + list_node_t *current = engine->circles->head; + do { + render_circle(current->data); + current = current->next; + } while (current != NULL); + + glEnd(); +} + +static void draw_frames() { glClearColor(0.0f, 0.0f, 0.2f, 1.0f); @@ -166,6 +193,7 @@ draw_frames() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); draw_lines(); + draw_circles(); engine_calculate_fps(); } |