comparison src/painter.h @ 28:783841af4033

core: implement painter API, closes #2451 @1h
author David Demelier <markand@malikania.fr>
date Mon, 13 Jan 2020 12:21:31 +0100
parents
children 3996f873a54b
comparison
equal deleted inserted replaced
27:607bd90aba63 28:783841af4033
1 /*
2 * painter.h -- basic drawing routines
3 *
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef MOLKO_PAINTER_H
20 #define MOLKO_PAINTER_H
21
22 /**
23 * \file painter.h
24 * \brief Basic drawing routines.
25 */
26
27 #include <stdbool.h>
28 #include <stdint.h>
29
30 struct texture;
31
32 /**
33 * Set the rendering context to the given texture.
34 *
35 * If texture is NULL, use default context aka the window.
36 *
37 * \param tex the texture
38 */
39 void
40 painter_use(struct texture *tex);
41
42 /**
43 * Get the current drawing color.
44 *
45 * \return the color in RRGGBBAA format
46 */
47 uint32_t
48 painter_get_color(void);
49
50 /**
51 * Set the rendering drawing color.
52 *
53 * \param color in RRGGBBAA format
54 */
55 void
56 painter_set_color(uint32_t color);
57
58 /**
59 * Draw a line.
60 *
61 * \param x1 first X coordinate
62 * \param y1 first Y coordinate
63 * \param x2 second X coordinate
64 * \param y2 second Y coordinate
65 */
66 void
67 painter_draw_line(int x1, int y1, int x2, int y2);
68
69 /**
70 * Draw a pixel point.
71 *
72 * \param x the X coordinate
73 * \param y the Y coordinate
74 */
75 void
76 painter_draw_point(int x, int y);
77
78 /**
79 * Draw a rectangle
80 *
81 * \param fill set to true to fill the rectangle
82 * \param x the X coordinate
83 * \param y the Y coordinate
84 * \param w the rectangle width
85 * \param h the rectangle height
86 */
87 void
88 painter_draw_rectangle(bool fill, int x, int y, unsigned w, unsigned h);
89
90 /**
91 * Clear the window.
92 */
93 void
94 painter_clear(void);
95
96 /**
97 * Present the window, only call this function one time in the main loop.
98 */
99 void
100 painter_present(void);
101
102 #endif /* !MOLKO_PAINTER_H */