summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdimension/canvas.c13
-rw-r--r--libdimension/dimension/canvas.h1
-rw-r--r--tests/libdimension/gl.c2
3 files changed, 16 insertions, 0 deletions
diff --git a/libdimension/canvas.c b/libdimension/canvas.c
index 2d0df2e..14bc156 100644
--- a/libdimension/canvas.c
+++ b/libdimension/canvas.c
@@ -95,3 +95,16 @@ dmnsn_set_pixel(dmnsn_canvas *canvas, unsigned int x, unsigned int y,
(*optimizer.optimizer_fn)(canvas, optimizer, x, y);
}
}
+
+/* Fill a canvas with a solid color */
+void
+dmnsn_clear_canvas(dmnsn_canvas *canvas, dmnsn_color color)
+{
+ unsigned int x;
+ for (x = 0; x < canvas->x; ++x) {
+ unsigned int y;
+ for (y = 0; y < canvas->y; ++y) {
+ dmnsn_set_pixel(canvas, x, y, color);
+ }
+ }
+}
diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h
index 67b88df..306b55c 100644
--- a/libdimension/dimension/canvas.h
+++ b/libdimension/dimension/canvas.h
@@ -75,5 +75,6 @@ dmnsn_get_pixel(const dmnsn_canvas *canvas, unsigned int x, unsigned int y)
void dmnsn_set_pixel(dmnsn_canvas *canvas, unsigned int x, unsigned int y,
dmnsn_color color);
+void dmnsn_clear_canvas(dmnsn_canvas *canvas, dmnsn_color color);
#endif /* DIMENSION_CANVAS_H */
diff --git a/tests/libdimension/gl.c b/tests/libdimension/gl.c
index 24a8ccd..00f9819 100644
--- a/tests/libdimension/gl.c
+++ b/tests/libdimension/gl.c
@@ -45,6 +45,8 @@ main() {
return EXIT_FAILURE;
}
+ dmnsn_clear_canvas(scene->canvas, dmnsn_black);
+
/* Create a new glX display */
display = dmnsn_new_display(scene->canvas);
if (!display) {