Mercurial > molko
comparison src/window.h @ 1:03f6d572fd17
core: implement basic drawing, closes #2438
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 06 Jan 2020 13:06:52 +0100 |
parents | efcc908bca21 |
children | 832c20d6cce9 |
comparison
equal
deleted
inserted
replaced
0:efcc908bca21 | 1:03f6d572fd17 |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #ifndef MOLKO_WINDOW_H | 19 #ifndef MOLKO_WINDOW_H |
20 #define MOLKO_WINDOW_H | 20 #define MOLKO_WINDOW_H |
21 | 21 |
22 /** | |
23 * \file window.h | |
24 * \brief Basic window management. | |
25 */ | |
26 | |
22 #include <stdbool.h> | 27 #include <stdbool.h> |
28 #include <stdint.h> | |
23 | 29 |
30 /** | |
31 * \brief Window opaque object. | |
32 */ | |
24 struct window; | 33 struct window; |
25 | 34 |
35 /** | |
36 * Initialize window. | |
37 * | |
38 * \pre title != NULL | |
39 * \param title the window title | |
40 * \param width the desired width | |
41 * \param height the desired height | |
42 * \return the window or NULL on error | |
43 */ | |
26 struct window * | 44 struct window * |
27 window_init(const char *name, unsigned width, unsigned height); | 45 window_init(const char *title, unsigned width, unsigned height); |
28 | 46 |
47 /** | |
48 * Get the current drawing color. | |
49 * | |
50 * \pre window != NULL | |
51 * \param window the window | |
52 * \return the color in RRGGBBAA format | |
53 */ | |
54 uint32_t | |
55 window_get_color(const struct window *window); | |
56 | |
57 /** | |
58 * Set the rendering drawing color. | |
59 * | |
60 * \pre window != NULL | |
61 * \param window the window | |
62 * \param color in RRGGBBAA format | |
63 */ | |
64 void | |
65 window_set_color(struct window *window, uint32_t color); | |
66 | |
67 /** | |
68 * Draw a line. | |
69 * | |
70 * \pre window != NULL | |
71 * \param window the window | |
72 * \param x1 first X coordinate | |
73 * \param y1 first Y coordinate | |
74 * \param x2 second X coordinate | |
75 * \param y2 second Y coordinate | |
76 */ | |
77 void | |
78 window_draw_line(struct window *window, int x1, int y1, int x2, int y2); | |
79 | |
80 /** | |
81 * Draw a pixel point. | |
82 * | |
83 * \pre window != NULL | |
84 * \param window the window | |
85 * \param x the X coordinate | |
86 * \param y the Y coordinate | |
87 */ | |
88 void | |
89 window_draw_point(struct window *window, int x, int y); | |
90 | |
91 /** | |
92 * Draw a rectangle | |
93 * | |
94 * \pre window != NULL | |
95 * \param window the window | |
96 * \param fill set to true to fill the rectangle | |
97 * \param x the X coordinate | |
98 * \param y the Y coordinate | |
99 * \param w the rectangle width | |
100 * \param h the rectangle height | |
101 */ | |
102 void | |
103 window_draw_rectangle(struct window *window, | |
104 bool fill, | |
105 int x, | |
106 int y, | |
107 unsigned w, | |
108 unsigned h); | |
109 | |
110 /** | |
111 * Clear the window. | |
112 * | |
113 * \pre window != NULL | |
114 * \param window the window | |
115 */ | |
116 void | |
117 window_clear(struct window *window); | |
118 | |
119 /** | |
120 * Present the window, only call this function one time in the main loop. | |
121 * | |
122 * \pre window != NULL | |
123 * \param window the window | |
124 */ | |
125 void | |
126 window_present(struct window *window); | |
127 | |
128 /** | |
129 * Close the window and destroy associated resources, do not use pointer | |
130 * afterwards. | |
131 * | |
132 * \pre window != NULL | |
133 * \param window the window | |
134 */ | |
29 void | 135 void |
30 window_close(struct window *window); | 136 window_close(struct window *window); |
31 | 137 |
32 #endif /* !MOLKO_WINDOW_H */ | 138 #endif /* !MOLKO_WINDOW_H */ |