1 #pragma once
2 
3 #include "globalincs/pstypes.h"
4 #include "graphics/2d.h"
5 
6 /**
7  * @brief Flashes the screen with the specified color
8  * @param r The red color value
9  * @param g The green color value
10  * @param b The blue color value
11  */
12 void gr_flash( int r, int g, int b );
13 /**
14  * @brief Flashes the screen with the specified color with an alpha value
15  * @param r The red color value
16  * @param g The green color value
17  * @param b The blue color value
18  * @param a The alpha value of the flash
19  */
20 void gr_flash_alpha(int r, int g, int b, int a);
21 
22 /**
23  * @brief Draws a grey-scale bitmap multiplied with the current color
24  * @param x The x-coordinate of the draw call
25  * @param y The y-coordinate of the draw call
26  * @param resize_mode The resize mode for translating the coordinated
27  * @param mirror @c true to mirror the image
28  */
29 void gr_aabitmap(int x, int y, int resize_mode = GR_RESIZE_FULL, bool mirror = false);
30 /**
31  * @brief Draws a grey-scale bitmap multiplied with the current color
32  * @param x The x-coordinate of the draw call
33  * @param y The y-coordinate of the draw call
34  * @param w
35  * @param h
36  * @param sx
37  * @param sy
38  * @param resize_mode The resize mode for translating the coordinated
39  * @param mirror @c true to mirror the image
40  */
41 void gr_aabitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode = GR_RESIZE_FULL, bool mirror = false);
42 /**
43  * @brief Draws a normal-colored bitmap to the screen
44  * @param x The x-coordinate of the draw call
45  * @param y The y-coordinate of the draw call
46  * @param w
47  * @param h
48  * @param sx
49  * @param sy
50  * @param resize_mode The resize mode for translating the coordinated
51  */
52 void gr_bitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode = GR_RESIZE_FULL);
53 
54 /**
55  * @brief Renders the specified string to the screen using the current font and color
56  * @param x The x-coordinate
57  * @param y The y-coordinate
58  * @param string The string to draw to the screen
59  * @param resize_mode The mode for translating the screen positions
60  * @param length The number of bytes in the string to render. -1 will render the whole string.
61  */
62 void gr_string(float x, float y, const char* string, int resize_mode = GR_RESIZE_FULL, int length = -1);
63 /**
64  * @brief Renders the specified string to the screen using the current font and color
65  * @param x The x-coordinate
66  * @param y The y-coordinate
67  * @param string The string to draw to the screen
68  * @param resize_mode The mode for translating the screen positions
69  * @param length The number of bytes in the string to render. -1 will render the whole string.
70  */
71 inline void gr_string(int x, int y, const char* string, int resize_mode = GR_RESIZE_FULL, int length = -1)
72 {
73 	gr_string(i2fl(x), i2fl(y), string, resize_mode, length);
74 }
75 
76 /**
77  * @brief Draws a single line segment to the screen.
78  * @param x1 The starting x-coordinate
79  * @param y1 The starting y-coordinate
80  * @param x2 The end x-coordinate
81  * @param y2 The end y-coordinate
82  * @param resize_mode The resize mode for translating screen positions
83  */
84 void gr_line(int x1, int y1, int x2, int y2, int resize_mode = GR_RESIZE_FULL);
85 /**
86  * @brief Draws an antialiased line is the current color is an alphacolor, otherwise just draws a fast line.
87  * This gets called internally by g3_draw_line. This assumes he vertex's are already clipped, so call g3_draw_line
88  * not this if you have two 3d points.
89  * @param v1 The starting position
90  * @param v2 The end position
91  */
92 void gr_aaline(vertex *v1, vertex *v2);
93 /**
94  * @brief Draw a gradient line... x1,y1 is bright, x2,y2 is transparent.
95  * @param x1 The starting x-coordinate
96  * @param y1 The starting y-coordinate
97  * @param x2 The end x-coordinate
98  * @param y2 The end y-coordinate
99  * @param resize_mode The resize mode for translating screen positions
100  */
101 void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode = GR_RESIZE_FULL);
102 /**
103  * @brief Sets the specified pixel to the current color
104  * @param x The x-coordinate
105  * @param y The y-coordinate
106  * @param resize_mode The mode for translating the screen positions
107  */
108 void gr_pixel(int x, int y, int resize_mode = GR_RESIZE_FULL);
109 
110 /**
111  * @brief Draws a filled rectangle with the current color
112  * @param x The x-coordinate
113  * @param y The y-coordinate
114  * @param w The width of the rectangle
115  * @param h The height of the rectangle
116  * @param resize_mode The mode for translating the screen positions
117  */
118 void gr_rect(int x, int y, int w, int h, int resize_mode = GR_RESIZE_FULL);
119 /**
120  * @brief Draws a filled rectangle with the current shading color
121  * @param x The x-coordinate
122  * @param y The y-coordinate
123  * @param w The width of the rectangle
124  * @param h The height of the rectangle
125  * @param resize_mode The mode for translating the screen positions
126  */
127 void gr_shade(int x, int y, int w, int h, int resize_mode = GR_RESIZE_FULL);
128 
129 /**
130  * @brief Draws a filled circle with the current color
131  * @param xc The center x-position of the circle
132  * @param yc The center y-position of the circle
133  * @param d The diameter of the circle
134  * @param resize_mode The mode for translating the screen positions
135  */
136 void gr_circle(int xc, int yc, int d, int resize_mode = GR_RESIZE_FULL);
137 /**
138  * @brief Draws an unfilled circle with the current color
139  * @param xc The center x-position of the circle
140  * @param yc The center y-position of the circle
141  * @param d The diameter of the circle
142  * @param resize_mode The mode for translating the screen positions
143  */
144 void gr_unfilled_circle(int xc, int yc, int d, int resize_mode = GR_RESIZE_FULL);
145 /**
146  * @brief Draws a limited circle arc from the specified start to the end angle
147  * @param xc The center x-position
148  * @param yc The center y-position
149  * @param r The radius of the arc
150  * @param angle_start The starting angle of the arc
151  * @param angle_end The end angle of the arc
152  * @param fill @c true to fill the arc segment
153  * @param resize_mode The mode for translating the screen positions
154  */
155 void gr_arc(int xc, int yc, float r, float angle_start, float angle_end, bool fill, int resize_mode = GR_RESIZE_FULL);
156 /**
157  * @brief Draws a 90° curve with the center at the specified coordinates
158  *
159  * The direction specified in which direction the curve should be drawn
160  *
161  * @param x The center x-position of the curve
162  * @param y The center y-position of the curve
163  * @param r The radius of the curve
164  * @param direction The direction to draw the curve
165  * @param resize_mode The mode for translating the screen positions
166  */
167 void gr_curve(int x, int y, int r, int direction, int resize_mode);
168 
169 /**
170  * @brief Start buffering 2D rendering operations
171  *
172  * This will defer rendering 2D interface elements until gr_2d_stop_buffer is called. This can improve performance when
173  * doing a lot of 2D operations since the actual drawing will only be done once.
174  *
175  * @warning This will only affect a few rendering operations and might change the drawing order if incompatible rendering
176  * commands are executed while the buffering mechanism is active.
177  */
178 void gr_2d_start_buffer();
179 
180 /**
181  * @brief Stop buffering 2D rendering operations
182  *
183  * This will stop the 2D buffering mechanism and also flush all previous render commands.
184  */
185 void gr_2d_stop_buffer();
186 
187 /**
188  * @brief The buffer object holding the data for immediate draws
189  */
190 extern gr_buffer_handle gr_immediate_buffer_handle;
191 
192 /**
193  * @brief Adds data to the immediate buffer for use by draw operations
194  *
195  * @warning The data is only available in the buffer for one frame.
196  *
197  * @param size The size of the data buffer
198  * @param data The pointer to the data
199  * @return The offset into the immediate buffer where this data starts at
200  */
201 size_t gr_add_to_immediate_buffer(size_t size, void *data);
202 
203 /**
204  * @brief Resets the immediate buffer for reuse
205  */
206 void gr_reset_immediate_buffer();
207 
208 /**
209  * @brief Renders some vertex data from an immediate memory buffer
210  * @param material_info The material information for rendering the data
211  * @param prim_type The primitive type of the data
212  * @param layout The vertex layout of the data
213  * @param n_verts How many vertices are in the data
214  * @param data The pointer to the data to render
215  * @param size The size of the data
216  */
217 void gr_render_primitives_immediate(material* material_info, primitive_type prim_type, vertex_layout* layout, int n_verts, void* data, size_t size);
218 
219 /**
220  * @brief Renders some vertex data from an immediate memory buffer with a 2D projection matrix
221  * @param material_info The material information for rendering the data
222  * @param prim_type The primitive type of the data
223  * @param layout The vertex layout of the data
224  * @param n_verts How many vertices are in the data
225  * @param data The pointer to the data to render
226  * @param size The size of the data
227  */
228 void gr_render_primitives_2d_immediate(material* material_info, primitive_type prim_type, vertex_layout* layout, int n_verts, void* data, size_t size);
229 
230 void gr_bitmap_list(bitmap_rect_list* list, int n_bm, int resize_mode);
231 
232 void gr_aabitmap_list(bitmap_rect_list* list, int n_bm, int resize_mode);
233