summaryrefslogtreecommitdiff
path: root/src/main/engine/shape
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/engine/shape')
-rw-r--r--src/main/engine/shape/circle.c11
-rw-r--r--src/main/engine/shape/circle.h1
-rw-r--r--src/main/engine/shape/line.c7
-rw-r--r--src/main/engine/shape/line.h2
4 files changed, 18 insertions, 3 deletions
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__ */