From 7c7dc660e587eac1aa3c8b3405eba95ba558e682 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Sat, 15 Jun 2019 14:28:29 +0100 Subject: 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. --- src/canvas.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/canvas.h (limited to 'src/canvas.h') 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 -- cgit v1.2.3