aboutsummaryrefslogtreecommitdiff
path: root/src/canvas.h
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-06-15 14:28:29 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-07-03 20:50:19 +0100
commit7c7dc660e587eac1aa3c8b3405eba95ba558e682 (patch)
tree81d12d560b60d397be23c7d132e32a5de30e409a /src/canvas.h
parent20e9d23b82f55a751c3cf1166cb59ef26775ee00 (diff)
downloadimv-7c7dc660e587eac1aa3c8b3405eba95ba558e682.tar.gz
Big glfw refactor
I did a lot of this in a very ad-hoc fashion with no proper commit history. As such, the kindest thing to do seemed to be to just squash it into this one commit.
Diffstat (limited to 'src/canvas.h')
-rw-r--r--src/canvas.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/canvas.h b/src/canvas.h
new file mode 100644
index 0000000..4f520fe
--- /dev/null
+++ b/src/canvas.h
@@ -0,0 +1,51 @@
+#ifndef IMV_CANVAS_H
+#define IMV_CANVAS_H
+
+struct imv_canvas;
+struct imv_image;
+
+enum upscaling_method {
+ UPSCALING_LINEAR,
+ UPSCALING_NEAREST_NEIGHBOUR,
+ UPSCALING_METHOD_COUNT,
+};
+
+/* Create a canvas instance */
+struct imv_canvas *imv_canvas_create(int width, int height);
+
+/* Clean up a canvas */
+void imv_canvas_free(struct imv_canvas *canvas);
+
+/* Set the buffer size of the canvas */
+void imv_canvas_resize(struct imv_canvas *canvas, int width, int height);
+
+/* Blank the canvas to be empty and transparent */
+void imv_canvas_clear(struct imv_canvas *canvas);
+
+/* Set the current drawing color of the canvas */
+void imv_canvas_color(struct imv_canvas *canvas, float r, float g, float b, float a);
+
+/* Fill a rectangle on the canvas with the current color */
+void imv_canvas_fill_rectangle(struct imv_canvas *canvas, int x, int y, int width, int height);
+
+/* Fill the whole canvas with the current color */
+void imv_canvas_fill(struct imv_canvas *canvas);
+
+/* Fill the whole canvas with a chequerboard pattern */
+void imv_canvas_fill_checkers(struct imv_canvas *canvas, int size);
+
+/* Select the font to draw text with */
+void imv_canvas_font(struct imv_canvas *canvas, const char *name, int size);
+
+/* Draw some text on the canvas */
+void imv_canvas_printf(struct imv_canvas *canvas, int x, int y, const char *fmt, ...);
+
+/* Blit the canvas to the current OpenGL framebuffer */
+void imv_canvas_draw(struct imv_canvas *canvas);
+
+/* Blit the given image to the current OpenGL framebuffer */
+void imv_canvas_draw_image(struct imv_canvas *canvas, struct imv_image *image,
+ int x, int y, double scale,
+ enum upscaling_method upscaling_method);
+
+#endif