diff options
Diffstat (limited to 'src/main/engine')
-rw-r--r-- | src/main/engine/engine.c | 11 | ||||
-rw-r--r-- | src/main/engine/shape/circle.c | 11 | ||||
-rw-r--r-- | src/main/engine/shape/circle.h | 1 | ||||
-rw-r--r-- | src/main/engine/shape/line.c | 7 | ||||
-rw-r--r-- | src/main/engine/shape/line.h | 2 |
5 files changed, 27 insertions, 5 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index 495b960..d9477cc 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -96,14 +96,21 @@ engine_calculate_fps() } static void +engine_set_background(Engine *engine) +{ + if (engine == NULL || engine->rendering_background == NULL) return; + Color *bk = engine->rendering_background; + glClearColor(bk->r, bk->g, bk->b, bk->a); +} + +static void draw_frames(void *data) { if (data == NULL) return; Engine *engine = data; - Color *bk = engine->rendering_background; - glClearColor(bk->r, bk->g, bk->b, bk->a); + engine_set_background(engine); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); diff --git a/src/main/engine/shape/circle.c b/src/main/engine/shape/circle.c index f60e917..996ae19 100644 --- a/src/main/engine/shape/circle.c +++ b/src/main/engine/shape/circle.c @@ -40,6 +40,10 @@ engine_render_circle(Circle *circle) { glBegin(GL_LINE_LOOP); + if (circle->color != NULL) { + glColor3f(circle->color->r, circle->color->g, circle->color->b); + } + 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); @@ -49,3 +53,10 @@ engine_render_circle(Circle *circle) glEnd(); } + +void +engine_circle_set_color(Circle *circle, Color *color) +{ + if (circle == NULL) return; + circle->color = color; +} diff --git a/src/main/engine/shape/circle.h b/src/main/engine/shape/circle.h index 67c3a46..3830256 100644 --- a/src/main/engine/shape/circle.h +++ b/src/main/engine/shape/circle.h @@ -33,5 +33,6 @@ typedef struct { Circle *engine_circle_new(float cx, float cy, float r, int num_segments, int outline); void engine_render_circle(Circle *circle); +void engine_circle_set_color(Circle *, Color *); #endif /* __CIRCLE_H__ */ diff --git a/src/main/engine/shape/line.c b/src/main/engine/shape/line.c index 7c0bc18..c3ef502 100644 --- a/src/main/engine/shape/line.c +++ b/src/main/engine/shape/line.c @@ -47,13 +47,16 @@ engine_render_line(Line *line) } void -engine_render_lines(list_t *lines) +engine_render_lines(list_t *lines, Color *color) { if (lines == NULL || lines->size <= 0) return; glLineWidth(5.0f); glBegin(GL_LINES); - glColor3f(1.0f, 1.0f, 0.0f); /* Yellow */ + + if (color != NULL) { + glColor3f(color->r, color->g, color->b); + } list_node_t *current = lines->head; do { diff --git a/src/main/engine/shape/line.h b/src/main/engine/shape/line.h index c1a933d..ec589a9 100644 --- a/src/main/engine/shape/line.h +++ b/src/main/engine/shape/line.h @@ -30,6 +30,6 @@ typedef struct Line { Line *engine_line_new(float x1, float y1, float x2, float y2); void engine_render_line(Line *line); -void engine_render_lines(list_t *lines); +void engine_render_lines(list_t *lines, Color *color); #endif /* __ENGINE_LINE_H__ */ |