Debian Codegraph @

2dlib/gr.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/Lib/gr.h $
21 * $Revision: 18 $
22 * $Date: 4/17/99 6:15p $
23 * $Author: Samir $
24 *
25 * the 2d lib main header
26 *
27 * $Log: /DescentIII/Main/Lib/gr.h $
28 *
29 * 18 4/17/99 6:15p Samir
30 * replaced gr.h with grdefs.h and fixed resulting compile bugs.
31 *
32 * 17 4/14/99 3:59a Jeff
33 * fixed case mismatches in #includes
34 *
35 * 16 11/30/98 5:50p Jason
36 * added 4444 bitmap support
37 *
38 * 15 12/29/97 5:50p Samir
39 * Moved GR_COLOR_CHAR to grdefs.h from gr.h.
40 *
41 * 14 12/22/97 7:39p Samir
42 * Moved color constants from gr.h to grdefs.h
43 *
44 * 13 12/22/97 7:13p Samir
45 * Moved constants to grdefs.h
46 *
47 * 12 12/19/97 12:33p Samir
48 * Added alpha for text and took out abilitiy to create viewports inside
49 * viewports.
50 *
51 * 11 12/12/97 6:40p Samir
52 * Some viewport font functions.
53 *
54 * 10 11/16/97 6:54p Samir
55 * Added font::get_name function.
56 *
57 * 9 11/16/97 2:20p Samir
58 * Added macro to draw a bitmap to a viewport.
59 *
60 * 8 11/11/97 1:27p Samir
61 * Added functions to set text alpha values.
62 *
63 * 7 11/04/97 4:57p Samir
64 * Added get_text_color.
65 *
66 * 6 10/13/97 3:56p Jason
67 * made a better 3d bitmap system
68 *
69 * 5 10/03/97 11:59a Samir
70 * Added some color constants.
71 *
72 * 4 9/19/97 5:37p Samir
73 * Software font coloring works.
74 *
75 * 1 6/23/97 9:25p Samir
76 * added because source safe sucks
77 *
78 * 39 6/16/97 3:01p Samir
79 * Changed font system to work better with renderer. Fonts are rendered
80 * on bitmaps of 128x128 at load time.
81 *
82 * 38 6/12/97 6:30p Samir
83 * DDGR v2.0 Changes in 2d system implemented.
84 *
85 * 37 6/09/97 3:47p Jason
86 * fixed some color mapping problems
87 *
88 * 36 5/21/97 3:39p Jason
89 * added terrain editing stuff
90 *
91 * 35 5/21/97 1:08p Samir
92 * added conversion from 565 to ddgr_color format.
93 *
94 * 34 5/15/97 2:08p Samir
95 * Added grSurface::get_surface_desc and grViewport::get_parent.
96 *
97 * 33 5/13/97 6:36p Samir
98 * added lock_clear functions.
99 *
100 *
101 * $NoKeywords: $
102 */
103
104 #ifndef _GR_H
105 #define _GR_Hcxx . . $ `2dlib/gr.h:105:9`!
106
107 #include "Ddgr.h"cxx . . $ `<file>/lib/Ddgr.h`/
108 #include "fix.h"cxx . . $ `<file>/fix/fix.h`/
109 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
110
111 class grMemorySurfacecxx . . $ grMemorySurface#;
112 class grViewportcxx . . $ grViewport#;
113 class grSurfacecxx . . $ grSurface#;
114 class grPencxx . . $ grPen#;
115
116 // a 'pen' structure used by the 2d system to draw things.
117 struct gr_pencxx . . $ gr_pen# {
118 char *datacxx . . $ gr_pen#data.;
119 int rowsizecxx . . $ gr_pen#rowsize.;
120 ddgr_colorcxx . . $ ddgr_color# rgbcolorcxx . . $ gr_pen#rgbcolor.;
121 ddgr_colorcxx . . $ ddgr_color# colorcxx . . $ gr_pen#color.;
122 ddgr_surfacecxx . . $ ddgr_surface# *sfcxx . . $ gr_pen#sf.;
123 };
124
125 enum grTextAligncxx . . $ grTextAlign# { // used to align text along viewport
126 grTextUnjustifiedcxx . . $ grTextUnjustified.,
127 grTextLeftcxx . . $ grTextLeft.,
128 grTextCenteredcxx . . $ grTextCentered.,
129 grTextRightcxx . . $ grTextRight.,
130 grTextWordWrapcxx . . $ grTextWordWrap.
131 };
132
133 struct tCharPropertiescxx . . $ tCharProperties# {
134 uint8_tcxx . . $ uint8_t# alphacxx . . $ tCharProperties#alpha.;
135 ddgr_colorcxx . . $ ddgr_color# colcxx . . $ tCharProperties#col.[4];
136 };
137
138 #define GR_VPCP_ALPHAcxx . . $ `2dlib/gr.h:138:9`! 1 // alpha value is valid in CharProperties
139 #define GR_VPCP_COLORcxx . . $ `2dlib/gr.h:139:9`! 2 // color values are valid in CharProperties.
140 #define GR_VPCP_ALLcxx . . $ `2dlib/gr.h:140:9`! (1 + 2)
141
142 // ----------------------------------------------------------------------------
143 // class grFont
144 // will load and manage a font's capabilities.
145 // all fonts are stored in a 16bit hicolor format, or bitmasked.
146 // ----------------------------------------------------------------------------
147
148 const int MAX_FONTScxx . . $ MAX_FONTS. = 16, MAX_FONT_BITMAPScxx . . $ MAX_FONT_BITMAPS. = 12;
149
150 #define DEFAULT_FONTcxx . . $ `2dlib/gr.h:150:9`! 0
151
152 struct gr_font_file_recordcxx . . $ gr_font_file_record# {
153 int16_t widthcxx . . $ gr_font_file_record#width., heightcxx . . $ gr_font_file_record#height.; // width of widest character and height of longest char
154 int16_t flagscxx . . $ gr_font_file_record#flags.; // flags used by the character renderer
155 int16_t baselinecxx . . $ gr_font_file_record#baseline.; // pixels given to lowercase below script line start at baseline
156 uint8_tcxx . . $ uint8_t# min_asciicxx . . $ gr_font_file_record#min_ascii.; // minimum ascii value used by font
157 uint8_tcxx . . $ uint8_t# max_asciicxx . . $ gr_font_file_record#max_ascii.; // max ascii value used by the font
158 int16_t byte_widthcxx . . $ gr_font_file_record#byte_width.; // width of a character in the font in bytes
159 uint8_tcxx . . $ uint8_t# *raw_datacxx . . $ gr_font_file_record#raw_data.; // pixel, map data.
160 uint8_tcxx . . $ uint8_t# **char_datacxx . . $ gr_font_file_record#char_data.; // pointers to each character
161 int16_t *char_widthscxx . . $ gr_font_file_record#char_widths.; // individual pixel widths of each character
162 uint8_tcxx . . $ uint8_t# *kern_datacxx . . $ gr_font_file_record#kern_data.; // kerning information for specific letter combos
163 };
164
165 struct gr_font_recordcxx . . $ gr_font_record# {
166 char namecxx . . $ gr_font_record#name.[32];
167 char filenamecxx . . $ gr_font_record#filename.[32]; // filename of font
168 int referencescxx . . $ gr_font_record#references.; // number of references of that font
169 int bmpscxx . . $ gr_font_record#bmps.[MAX_FONT_BITMAPScxx . . $ MAX_FONT_BITMAPS.]; // font bitmap handles
170 grMemorySurfacecxx . . $ grMemorySurface# *surfscxx . . $ gr_font_record#surfs.[MAX_FONT_BITMAPScxx . . $ MAX_FONT_BITMAPS.];
171 uint8_tcxx . . $ uint8_t# *ch_ucxx . . $ gr_font_record#ch_u., *ch_vcxx . . $ gr_font_record#ch_v., *ch_wcxx . . $ gr_font_record#ch_w., *ch_hcxx . . $ gr_font_record#ch_h., *ch_surfcxx . . $ gr_font_record#ch_surf.;
172 float *ch_ufcxx . . $ gr_font_record#ch_uf., *ch_vfcxx . . $ gr_font_record#ch_vf., *ch_wfcxx . . $ gr_font_record#ch_wf., *ch_hfcxx . . $ gr_font_record#ch_hf.;
173 gr_font_file_recordcxx . . $ gr_font_file_record# fontcxx . . $ gr_font_record#font.;
174
175 };
176
177 class grFontcxx . . $ grFont# {
178 static gr_font_recordcxx . . $ gr_font_record# m_FontListcxx . . $ grFont#m_FontList.[MAX_FONTScxx . . $ MAX_FONTS.];
179 static grMemorySurfacecxx . . $ grMemorySurface# *m_CharSurfcxx . . $ grFont#m_CharSurf.;
180
181 int m_FontHandlecxx . . $ grFont#m_FontHandle.; // offset into m_FontList
182
183 public:
184 grFontcxx . . $ grFont#grFont(49f6e7a06ebc5aa8).();
185 ~cxx . . $ grFont#`~grFont`(49f6e7a06ebc5aa8).grFontcxx . . $ grFont#();
186 grFontcxx . . $ grFont#grFont(e0d72de78c8274e3).(const grFontcxx . . $ grFont# &font) { m_FontHandlecxx . . $ grFont#m_FontHandle. = font.m_FontHandlecxx . . $ grFont#m_FontHandle.; };
187
188 const grFontcxx . . $ grFont# &operatorcxx . . $ grFont#`operator=`(4193a2fe8f1b874f).=(const grFontcxx . . $ grFont# &font) {
189 m_FontHandlecxx . . $ grFont#m_FontHandle. = font.m_FontHandlecxx . . $ grFont#m_FontHandle.;
190 return *this;
191 };
192
193 public: // Manipulation functions
194 static void init_systemcxx . . $ grFont#init_system(49f6e7a06ebc5aa8).();
195 static void close_systemcxx . . $ grFont#close_system(49f6e7a06ebc5aa8).();
196 static int register_fontcxx . . $ grFont#register_font(e99f026884c896d5).(char *fontname, char *filename);
197
198 void initcxx . . $ grFont#init(85c52e162fed56f9).(const char *fontname);
199 void freecxx . . $ grFont#free(49f6e7a06ebc5aa8).();
200
201 // draw_char returns the next x value taking spacing and kerning into consideration.
202 int draw_charcxx . . $ grFont#draw_char(222b2b3cf8cd66cf).(grSurfacecxx . . $ grSurface# *sf, int x, int y, int ch, tCharPropertiescxx . . $ tCharProperties# *chprop);
203 int draw_charcxx . . $ grFont#draw_char(9867803b38a2387f).(grSurfacecxx . . $ grSurface# *sf, int x, int y, int ch, int sx, int sy, int sw, int sh, tCharPropertiescxx . . $ tCharProperties# *chprop);
204
205 private:
206 static void free_fontcxx . . $ grFont#free_font(fe8ae557a2cea0).(gr_font_recordcxx . . $ gr_font_record# *ft);
207
208 static void loadcxx . . $ grFont#load(a07d8cccb7673f5a).(char *filename, int slot);
209 static void translate_to_surfacescxx . . $ grFont#translate_to_surfaces(d4f767463ce0a6b3).(int slot);
210 static void translate_mono_charcxx . . $ grFont#translate_mono_char(f04fccacaaac6574).(grSurfacecxx . . $ grSurface# *sf, int x, int y, int index, gr_font_file_recordcxx . . $ gr_font_file_record# *ft, int width);
211
212 uint8_tcxx . . $ uint8_t# *get_kern_infocxx . . $ grFont#get_kern_info(59fcd22a18ea873d).(uint8_tcxx . . $ uint8_t# c1, uint8_tcxx . . $ uint8_t# c2);
213 void charblt16cxx . . $ grFont#charblt16(12c723590b6d1aa0).(grSurfacecxx . . $ grSurface# *dsf, ddgr_colorcxx . . $ ddgr_color# col, int dx, int dy, grSurfacecxx . . $ grSurface# *ssf, int sx, int sy, int sw, int sh);
214
215 public: // Accessor functions
216 char *get_namecxx . . $ grFont#get_name(e7e5aa338b9d5147).() const {
217 if (m_FontHandlecxx . . $ grFont#m_FontHandle. == -1)
218 return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
219 else
220 return m_FontListcxx . . $ grFont#m_FontList.[m_FontHandlecxx . . $ grFont#m_FontHandle.].namecxx . . $ gr_font_record#name.;
221 };
222 int min_asciicxx . . $ grFont#min_ascii(455f465bc33b4cdf).() const {
223 ASSERTcxx . . $ grFont#m_FontHandle.(m_FontHandle > -1);
224 return m_FontListcxx . . $ grFont#m_FontList.[m_FontHandlecxx . . $ grFont#m_FontHandle.].fontcxx . . $ gr_font_record#font..min_asciicxx . . $ gr_font_file_record#min_ascii.;
225 };
226 int max_asciicxx . . $ grFont#max_ascii(455f465bc33b4cdf).() const {
227 ASSERTcxx . . $ grFont#m_FontHandle.(m_FontHandle > -1);
228 return m_FontListcxx . . $ grFont#m_FontList.[m_FontHandlecxx . . $ grFont#m_FontHandle.].fontcxx . . $ gr_font_record#font..max_asciicxx . . $ gr_font_file_record#max_ascii.;
229 };
230 int heightcxx . . $ grFont#height(455f465bc33b4cdf).() const {
231 ASSERTcxx . . $ `misc/pserror.h:246:9`!(m_FontHandle > -1);
232 return m_FontListcxx . . $ grFont#m_FontList.[m_FontHandlecxx . . $ grFont#m_FontHandle.].fontcxx . . $ gr_font_record#font..heightcxx . . $ gr_font_file_record#height.;
233 };
234 int get_char_infocxx . . $ grFont#get_char_info(ac48f4a6ffa9e770).(int ch, int *width);
235 };
236
237 // ----------------------------------------------------------------------------
238 // class grSurface
239 // contains a ddgr_bitmap object and allows for blting
240 // ----------------------------------------------------------------------------
241
242 struct ddgr_surface_nodecxx . . $ ddgr_surface_node# {
243 ddgr_surfacecxx . . $ ddgr_surface# *sfcxx . . $ ddgr_surface_node#sf.;
244 ddgr_surface_nodecxx . . $ ddgr_surface_node# *prevcxx . . $ ddgr_surface_node#prev.;
245 };
246
247 const int SURFTYPE_MEMORYcxx . . $ SURFTYPE_MEMORY. = 256;
248
249 const int SURFFLAG_RENDERERcxx . . $ SURFFLAG_RENDERER. = 256; // SURFACE will use renderer functions.
250
251 class grSurfacecxx . . $ grSurface# {
252 public:
253 static void init_systemcxx . . $ grSurface#init_system(49f6e7a06ebc5aa8).(); // initializes some global stuff for surface system
254 static void close_systemcxx . . $ grSurface#close_system(49f6e7a06ebc5aa8).();
255
256 private:
257 friend class grViewportcxx . . $ grViewport#;
258 int surf_Lockedcxx . . $ grSurface#surf_Locked.; // same value for all grViewport objects
259 int m_SurfInitcxx . . $ grSurface#m_SurfInit.; // surface initialized
260 char *m_OrigDataPtrcxx . . $ grSurface#m_OrigDataPtr.; // non-adjusted data pointer
261 char *m_DataPtrcxx . . $ grSurface#m_DataPtr.; // adjusted data pointer
262 int m_DataRowsizecxx . . $ grSurface#m_DataRowsize.; // Data rowsize
263
264 static ddgr_surface_nodecxx . . $ ddgr_surface_node# *surf_listcxx . . $ grSurface#surf_list.; // the surface list
265 static ddgr_surface_nodecxx . . $ ddgr_surface_node# *surf_list_curcxx . . $ grSurface#surf_list_cur.; // current node on list.
266 static ddgr_surfacecxx . . $ ddgr_surface# *scratch_mem_surfcxx . . $ grSurface#scratch_mem_surf.; // use as temporary memory surface
267
268 private:
269 // coversion blts.
270 void xlat8_16cxx . . $ grSurface#xlat8_16(1428750e2ba86a39).(char *data, int w, int h, char *pal);
271 void xlat16_16cxx . . $ grSurface#xlat16_16(51648a5edc2089b5).(char *data, int w, int h, int format = 0);
272 void xlat16_24cxx . . $ grSurface#xlat16_24(dcbbfe1ffd04514b).(char *data, int w, int h);
273 void xlat24_16cxx . . $ grSurface#xlat24_16(dcbbfe1ffd04514b).(char *data, int w, int h);
274 void xlat32_16cxx . . $ grSurface#xlat32_16(dcbbfe1ffd04514b).(char *data, int w, int h);
275
276 void unibltcxx . . $ grSurface#uniblt(ff120d6cc88a52cd).(int dx, int dy, grSurfacecxx . . $ grSurface# *ssf, int sx, int sy, int sw, int sh);
277
278 protected:
279 ddgr_surfacecxx . . $ ddgr_surface# ddsfObjcxx . . $ grSurface#ddsfObj.; // Used to call ddgr_surf_ functions
280
281 protected:
282 void add_to_listcxx . . $ grSurface#add_to_list(b6325dd6f6bb1424).(ddgr_surfacecxx . . $ ddgr_surface# *sf); // used for surface heap management
283 void remove_from_listcxx . . $ grSurface#remove_from_list(b6325dd6f6bb1424).(ddgr_surfacecxx . . $ ddgr_surface# *sf);
284
285 int surf_initcxx . . $ grSurface#surf_init(455f465bc33b4cdf).() const { return m_SurfInitcxx . . $ grSurface#m_SurfInit.; };
286 void surf_initcxx . . $ grSurface#surf_init(d4f767463ce0a6b3).(int init) { m_SurfInitcxx . . $ grSurface#m_SurfInit. = init; };
287
288 public:
289 grSurfacecxx . . $ grSurface#grSurface(49f6e7a06ebc5aa8).();
290 virtual ~cxx . . $ grSurface#`~grSurface`(ced63f7c635d850d).grSurfacecxx . . $ grSurface#();
291
292 // creates a surface, allocates memory based off of parameters.
293 grSurfacecxx . . $ grSurface#grSurface(589a245ae52835fb).(int w, int h, int bpp, unsigned type, unsigned flags = 0, const char *name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
294
295 public:
296 unsigned get_flagscxx . . $ grSurface#get_flags(ddd8539a2fcdd4ce).() const { return ddsfObjcxx . . $ grSurface#ddsfObj..flagscxx . . $ ddgr_surface#flags.; };
297
298 void createcxx . . $ grSurface#create(589a245ae52835fb).(int w, int h, int bpp, unsigned type, unsigned flags = 0, const char *name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
299
300 void loadcxx . . $ grSurface#load(e90830e4537cf0fa).(char *data, int w, int h, int bpp, int format = 0);
301 void loadcxx . . $ grSurface#load(d4f767463ce0a6b3).(int handle);
302 void loadcxx . . $ grSurface#load(1428750e2ba86a39).(char *data, int w, int h, char *pal);
303 void loadcxx . . $ grSurface#load(577809987ad7a468).(int handle, char *pal);
304
305 void freecxx . . $ grSurface#free(49f6e7a06ebc5aa8).(); // non-dynamic version
306
307 int widthcxx . . $ grSurface#width(455f465bc33b4cdf).() const {
308 ASSERTcxx . . $ grSurface#m_SurfInit.(m_SurfInit);
309 return ddsfObjcxx . . $ grSurface#ddsfObj..wcxx . . $ ddgr_surface#w.;
310 };
311 int heightcxx . . $ grSurface#height(455f465bc33b4cdf).() const {
312 ASSERTcxx . . $ `misc/pserror.h:246:9`!(m_SurfInit);
313 return ddsfObjcxx . . $ grSurface#ddsfObj..hcxx . . $ ddgr_surface#h.;
314 };
315 int bppcxx . . $ grSurface#bpp(455f465bc33b4cdf).() const {
316 ASSERTcxx . . $ grSurface#m_SurfInit.(m_SurfInit);
317 return ddsfObjcxx . . $ grSurface#ddsfObj..bppcxx . . $ ddgr_surface#bpp.;
318 };
319 unsigned flagscxx . . $ grSurface#flags(ddd8539a2fcdd4ce).() const {
320 ASSERTcxx . . $ `misc/pserror.h:246:9`!(m_SurfInit);
321 return ddsfObjcxx . . $ grSurface#ddsfObj..flagscxx . . $ ddgr_surface#flags.;
322 };
323
324 int rowsizecxx . . $ grSurface#rowsize(455f465bc33b4cdf).() const {
325 ASSERTcxx . . $ grSurface#m_SurfInit.(m_SurfInit);
326 return m_DataRowsizecxx . . $ grSurface#m_DataRowsize.;
327 };
328 char *datacxx . . $ grSurface#data(e7e5aa338b9d5147).() const {
329 ASSERTcxx . . $ grSurface#m_SurfInit.(m_SurfInit);
330 return m_DataPtrcxx . . $ grSurface#m_DataPtr.;
331 };
332
333 void clearcxx . . $ grSurface#clear(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# col = 0);
334 void clearcxx . . $ grSurface#clear(6fb2c7d311165c4f).(int l, int t, int w, int h, ddgr_colorcxx . . $ ddgr_color# col = 0);
335 void replace_colorcxx . . $ grSurface#replace_color(b4d55b1286ff73e8).(ddgr_colorcxx . . $ ddgr_color# sc, ddgr_colorcxx . . $ ddgr_color# dc);
336
337 void bltcxx . . $ grSurface#blt(3c4a031b05aa6aa3).(int dx, int dy, grSurfacecxx . . $ grSurface# *ssf);
338 void bltcxx . . $ grSurface#blt(ff120d6cc88a52cd).(int dx, int dy, grSurfacecxx . . $ grSurface# *ssf, int sx, int sy, int sw, int sh);
339
340 char *lockcxx . . $ grSurface#lock(3f31f7b3b80edb32).(int *rowsize);
341 char *lockcxx . . $ grSurface#lock(f35eb304381040d9).(int x, int y, int *rowsize);
342 void unlockcxx . . $ grSurface#unlock(49f6e7a06ebc5aa8).();
343
344 void get_surface_desccxx . . $ grSurface#get_surface_desc(b6325dd6f6bb1424).(ddgr_surfacecxx . . $ ddgr_surface# *surf) { *surf =cxx . . $ ddgr_surface#`operator=`(1a068c12aa23caca). ddsfObjcxx . . $ grSurface#ddsfObj.; };
345
346 // This is VERY system dependent when called, sorry but I think this may be necessary
347 void attach_to_windowcxx . . $ grSurface#attach_to_window(cb2f890c2fdad230).(unsigned handle);
348 };
349
350 // ----------------------------------------------------------------------------
351 // class grMemorySurface
352 // this is a software bitmap not video driver dependant
353 // ----------------------------------------------------------------------------
354
355 class grMemorySurfacecxx . . $ grMemorySurface# : public grSurfacecxx . . $ grSurface# {
356 bool m_FirstTimeInitcxx . . $ grMemorySurface#m_FirstTimeInit.; // do special stuff if we are initializing for first time
357 bool m_AllowInitcxx . . $ grMemorySurface#m_AllowInit.; // we only allow initialization if we didn't create it.
358
359 public:
360 grMemorySurfacecxx . . $ grMemorySurface#grMemorySurface(49f6e7a06ebc5aa8).();
361 virtual ~cxx . . $ grMemorySurface#`~grMemorySurface`(ced63f7c635d850d).grMemorySurfacecxx . . $ grMemorySurface#();
362
363 // allocates a surface from system memory (quicker version of grSurface)
364 grMemorySurfacecxx . . $ grMemorySurface#grMemorySurface(f0b9f08e753626c2).(int w, int h, int bpp, unsigned flags = 0, const char *name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
365
366 // initializes a surface using a bitmap handle (no allocation)
367 grMemorySurfacecxx . . $ grMemorySurface#grMemorySurface(d4f767463ce0a6b3).(int bm);
368
369 // inititalizes a surface using raw data,width,rowsize info information.
370 bool initcxx . . $ grMemorySurface#init(fe591fed253a3675).(int w, int h, int bpp, char *data, int rowsize, unsigned flags = 0, const char *name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
371 };
372
373 // ----------------------------------------------------------------------------
374 // class grHardwareSurface
375 // this is a hardware bitmap allocated from the video driver
376 // ----------------------------------------------------------------------------
377
378 class grHardwareSurfacecxx . . $ grHardwareSurface# : public grSurfacecxx . . $ grSurface# {
379 public:
380 grHardwareSurfacecxx . . $ grHardwareSurface#grHardwareSurface(49f6e7a06ebc5aa8).();
381 grHardwareSurfacecxx . . $ grHardwareSurface#grHardwareSurface(f0b9f08e753626c2).(int w, int h, int bpp, unsigned flags = 0, const char *name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
382 virtual ~cxx . . $ grHardwareSurface#`~grHardwareSurface`(ced63f7c635d850d).grHardwareSurfacecxx . . $ grHardwareSurface#();
383
384 bool createcxx . . $ grHardwareSurface#create(f4698b8840d8db11).(int w, int h, int bpp, unsigned flags = 0, const char *name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
385 };
386
387 // ----------------------------------------------------------------------------
388 // class grScreen
389 // child class of grSurface. Handles initializing the screen, and
390 // is used by the grViewport class to draw onto the screen
391 // ----------------------------------------------------------------------------
392
393 class grScreencxx . . $ grScreen# : public grSurfacecxx . . $ grSurface# {
394 friend class grViewportcxx . . $ grViewport#;
395
396 public:
397 grScreencxx . . $ grScreen#grScreen(a29fdc847efe61dd).(int w, int h, int bpp, const char *name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
398 virtual ~cxx . . $ grScreen#`~grScreen`(ced63f7c635d850d).grScreencxx . . $ grScreen#();
399
400 void flipcxx . . $ grScreen#flip(49f6e7a06ebc5aa8).();
401 };
402
403 // ----------------------------------------------------------------------------
404 // class grViewport
405 // a viewport is a bounded rectangle on either a screen or bitmap.
406 // one should be able to draw any 2d object on a viewport region.
407 // ----------------------------------------------------------------------------
408
409 // contains state information for a viewport.
410 struct tVPStatecxx . . $ tVPState# {
411 grFontcxx . . $ grFont# fontcxx . . $ tVPState#font.;
412 int text_spacingcxx . . $ tVPState#text_spacing.;
413 int text_line_spacingcxx . . $ tVPState#text_line_spacing.;
414 tCharPropertiescxx . . $ tCharProperties# chpropscxx . . $ tVPState#chprops.;
415 };
416
417 class grViewportcxx . . $ grViewport# {
418 static int vp_Lockedcxx . . $ grViewport#vp_Locked.; // tells us if any viewport is locked
419 static grViewportcxx . . $ grViewport# *vp_Current_VPcxx . . $ grViewport#vp_Current_VP.; // current locked viewport
420
421 grFontcxx . . $ grFont# text_Fontcxx . . $ grViewport#text_Font.;
422 int text_Spacingcxx . . $ grViewport#text_Spacing.;
423 int text_Line_spacingcxx . . $ grViewport#text_Line_spacing.;
424 tCharPropertiescxx . . $ tCharProperties# char_Propscxx . . $ grViewport#char_Props.;
425
426 private:
427 void draw_textcxx . . $ grViewport#draw_text(3214887f5026ce05).(grTextAligncxx . . $ grTextAlign# align, int x, int y, char *str);
428 void draw_text_linecxx . . $ grViewport#draw_text_line(1839e3b9b1397d59).(int x, int y, char *str);
429 void draw_text_line_clipcxx . . $ grViewport#draw_text_line_clip(1839e3b9b1397d59).(int x, int y, char *str);
430 int clip_linecxx . . $ grViewport#clip_line(3139a728715e5e03).(int &l, int &t, int &r, int &b);
431 int clip_rectcxx . . $ grViewport#clip_rect(3139a728715e5e03).(int &x1, int &y1, int &x2, int &y2);
432
433 protected:
434 int vp_Leftcxx . . $ grViewport#vp_Left., vp_Topcxx . . $ grViewport#vp_Top., vp_Rightcxx . . $ grViewport#vp_Right., // viewport's global screen/bitmap bounds
435 vp_Bottomcxx . . $ grViewport#vp_Bottom.;
436
437 int vp_InitLeftcxx . . $ grViewport#vp_InitLeft., vp_InitTopcxx . . $ grViewport#vp_InitTop., vp_InitRightcxx . . $ grViewport#vp_InitRight., vp_InitBottomcxx . . $ grViewport#vp_InitBottom.; // viewport's initial global screen coords
438
439 grSurfacecxx . . $ grSurface# *sf_Parentcxx . . $ grViewport#sf_Parent.; // bitmap where viewport points to
440 gr_pencxx . . $ gr_pen# pen_Objcxx . . $ grViewport#pen_Obj.;
441
442 public:
443 grViewportcxx . . $ grViewport#grViewport(d2b842a68930ff26).(grScreencxx . . $ grScreen# *scr_parent);
444 grViewportcxx . . $ grViewport#grViewport(bfea4a94c1105442).(grSurfacecxx . . $ grSurface# *sf_parent);
445 ~cxx . . $ grViewport#`~grViewport`(49f6e7a06ebc5aa8).grViewportcxx . . $ grViewport#();
446
447 grSurfacecxx . . $ grSurface# *get_parentcxx . . $ grViewport#get_parent(f62ec5d8128d4eea).() const { return sf_Parentcxx . . $ grViewport#sf_Parent.; };
448
449 // these are the viewport's initial bounds with respect to parent surface
450 // these can't be changed.
451 int widthcxx . . $ grViewport#width(455f465bc33b4cdf).() const { return (vp_InitRightcxx . . $ grViewport#vp_InitRight. - vp_InitLeftcxx . . $ grViewport#vp_InitLeft.) + 1; };
452 int heightcxx . . $ grViewport#height(455f465bc33b4cdf).() const { return (vp_InitBottomcxx . . $ grViewport#vp_InitBottom. - vp_InitTopcxx . . $ grViewport#vp_InitTop.) + 1; };
453 int leftcxx . . $ grViewport#left(455f465bc33b4cdf).() const { return vp_InitLeftcxx . . $ grViewport#vp_InitLeft.; };
454 int topcxx . . $ grViewport#top(455f465bc33b4cdf).() const { return vp_InitTopcxx . . $ grViewport#vp_InitTop.; };
455 int rightcxx . . $ grViewport#right(455f465bc33b4cdf).() const { return vp_InitRightcxx . . $ grViewport#vp_InitRight.; };
456 int bottomcxx . . $ grViewport#bottom(455f465bc33b4cdf).() const { return vp_InitBottomcxx . . $ grViewport#vp_InitBottom.; };
457
458 // these clipping coordinates are local to the viewports initial rectangle, based off
459 // of parent surface. All 2d functions use these coords to base their drawing.
460 // If we draw at (0,0) and the clip region is at (80,90,200,160) then we will draw at 80,90.
461 int clip_widthcxx . . $ grViewport#clip_width(455f465bc33b4cdf).() const { return (vp_Rightcxx . . $ grViewport#vp_Right. - vp_Leftcxx . . $ grViewport#vp_Left.) + 1; };
462 int clip_heightcxx . . $ grViewport#clip_height(455f465bc33b4cdf).() const { return (vp_Bottomcxx . . $ grViewport#vp_Bottom. - vp_Topcxx . . $ grViewport#vp_Top.) + 1; };
463 int clip_leftcxx . . $ grViewport#clip_left(455f465bc33b4cdf).() const { return vp_Leftcxx . . $ grViewport#vp_Left.; };
464 int clip_topcxx . . $ grViewport#clip_top(455f465bc33b4cdf).() const { return vp_Topcxx . . $ grViewport#vp_Top.; };
465 int clip_rightcxx . . $ grViewport#clip_right(455f465bc33b4cdf).() const { return vp_Rightcxx . . $ grViewport#vp_Right.; };
466 int clip_bottomcxx . . $ grViewport#clip_bottom(455f465bc33b4cdf).() const { return vp_Bottomcxx . . $ grViewport#vp_Bottom.; };
467 void set_clipping_rectcxx . . $ grViewport#set_clipping_rect(748afa4755bc9595).(int left, int top, int right, int bottom);
468
469 // these convert local viewport coords to global screen/surface coords
470 int global_xcxx . . $ grViewport#global_x(7ccb52b1bfe01045).(int lx) const { return vp_InitLeftcxx . . $ grViewport#vp_InitLeft. + vp_Leftcxx . . $ grViewport#vp_Left. + lx; };
471 int global_ycxx . . $ grViewport#global_y(7ccb52b1bfe01045).(int ly) const { return vp_InitTopcxx . . $ grViewport#vp_InitTop. + vp_Topcxx . . $ grViewport#vp_Top. + ly; };
472 int local_xcxx . . $ grViewport#local_x(7ccb52b1bfe01045).(int gx) const { return gx - vp_Leftcxx . . $ grViewport#vp_Left. - vp_InitLeftcxx . . $ grViewport#vp_InitLeft.; };
473 int local_ycxx . . $ grViewport#local_y(7ccb52b1bfe01045).(int gy) const { return gy - vp_Topcxx . . $ grViewport#vp_Top. - vp_InitTopcxx . . $ grViewport#vp_InitTop.; };
474
475 // these functions set and restore the state of the viewport (font, colors, etc.)
476 void get_statecxx . . $ grViewport#get_state(2ac10c8cd52dc500).(tVPStatecxx . . $ tVPState# *state);
477 void set_statecxx . . $ grViewport#set_state(3da10eeccd9af7c3).(const tVPStatecxx . . $ tVPState# *state);
478
479 // bltting functions on viewport
480 void clearcxx . . $ grViewport#clear(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# col = 0); // clear with background color
481 void lock_clearcxx . . $ grViewport#lock_clear(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# col = 0); // software clear. must be used in lock
482 void lock_clearcxx . . $ grViewport#lock_clear(fe09a4b73d8d396f).(ddgr_colorcxx . . $ ddgr_color# col, int l, int t, int w, int h);
483 void bltcxx . . $ grViewport#blt(3c4a031b05aa6aa3).(int dx, int dy, grSurfacecxx . . $ grSurface# *ssf);
484 void bltcxx . . $ grViewport#blt(ff120d6cc88a52cd).(int dx, int dy, grSurfacecxx . . $ grSurface# *ssf, int sx, int sy, int sw, int sh);
485
486 public:
487 grSurfacecxx . . $ grSurface# *lockcxx . . $ grViewport#lock(acdc12544967986e).(); // lock and
488 void unlockcxx . . $ grViewport#unlock(49f6e7a06ebc5aa8).(); // unlock (implicitly locks surface)
489
490 friend grSurfacecxx . . $ grSurface# *VP_GET_DRAWING_SURFACEcxx . . $ VP_GET_DRAWING_SURFACE(acdc12544967986e).();
491 friend void VP_BEGIN_DRAWINGcxx . . $ VP_BEGIN_DRAWING(59a0bcebdff6b8ca).(grViewportcxx . . $ grViewport# *vp);
492 friend void VP_END_DRAWINGcxx . . $ VP_END_DRAWING(49f6e7a06ebc5aa8).();
493
494 // these functions only work on locked surfaces.
495 void hlinecxx . . $ grViewport#hline(10de3014ec658f6e).(ddgr_colorcxx . . $ ddgr_color#, int x1, int x2, int y1);
496 void linecxx . . $ grViewport#line(fe09a4b73d8d396f).(ddgr_colorcxx . . $ ddgr_color# color, int x1, int y1, int x2, int y2);
497 void rectcxx . . $ grViewport#rect(fe09a4b73d8d396f).(ddgr_colorcxx . . $ ddgr_color# color, int l, int t, int r, int b);
498 void fillrectcxx . . $ grViewport#fillrect(fe09a4b73d8d396f).(ddgr_colorcxx . . $ ddgr_color# color, int l, int t, int r, int b);
499 void setpixelcxx . . $ grViewport#setpixel(8c880916ccadf15d).(ddgr_colorcxx . . $ ddgr_color# col, int x, int y);
500 void setpixelccxx . . $ grViewport#setpixelc(8c880916ccadf15d).(ddgr_colorcxx . . $ ddgr_color# col, int x, int y);
501 ddgr_colorcxx . . $ ddgr_color# getpixelcxx . . $ grViewport#getpixel(58c590d1186ea715).(int x, int y);
502 ddgr_colorcxx . . $ ddgr_color# getpixelccxx . . $ grViewport#getpixelc(58c590d1186ea715).(int x, int y);
503 void circlecxx . . $ grViewport#circle(10de3014ec658f6e).(ddgr_colorcxx . . $ ddgr_color# col, int xc, int yc, int r);
504 void fillcirclecxx . . $ grViewport#fillcircle(10de3014ec658f6e).(ddgr_colorcxx . . $ ddgr_color# col, int xc, int yc, int r);
505 // end
506
507 public:
508 // These functions only work on locked surfaces
509 int printfcxx . . $ grViewport#printf(d6cf461368ff6cc0).(grTextAligncxx . . $ grTextAlign# align, int x, int y, char *fmt, ...);
510 int printfcxx . . $ grViewport#printf(13a7a0696f737ebf).(int x, int y, char *fmt, ...);
511 int putscxx . . $ grViewport#puts(76a9c7ba36c5c57d).(grTextAligncxx . . $ grTextAlign# align, int x, int y, char *str);
512 int putscxx . . $ grViewport#puts(56759362374d8228).(int x, int y, char *str);
513
514 // text formatting functions
515 public:
516 int get_text_line_widthcxx . . $ grViewport#get_text_line_width(1ef8e6ec083aabb9).(char *text);
517 void set_fontcxx . . $ grViewport#set_font(85c52e162fed56f9).(const char *fontname);
518 void get_fontcxx . . $ grViewport#get_font(a07d8cccb7673f5a).(char *fontname, int size);
519 int get_current_font_heightcxx . . $ grViewport#get_current_font_height(455f465bc33b4cdf).() const { return text_Fontcxx . . $ grViewport#text_Font..heightcxx . . $ grFont#height(455f465bc33b4cdf).(); };
520 int get_text_spacingcxx . . $ grViewport#get_text_spacing(455f465bc33b4cdf).() const { return text_Spacingcxx . . $ grViewport#text_Spacing.; };
521 int get_text_line_spacingcxx . . $ grViewport#get_text_line_spacing(455f465bc33b4cdf).() const { return text_Line_spacingcxx . . $ grViewport#text_Line_spacing.; };
522 void set_text_spacingcxx . . $ grViewport#set_text_spacing(d4f767463ce0a6b3).(int spacing) { text_Spacingcxx . . $ grViewport#text_Spacing. = spacing; };
523 void set_text_line_spacingcxx . . $ grViewport#set_text_line_spacing(d4f767463ce0a6b3).(int spacing) { text_Line_spacingcxx . . $ grViewport#text_Line_spacing. = spacing; };
524
525 // visual properties of text functions
526 public:
527 void set_text_colorcxx . . $ grViewport#set_text_color(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# color);
528 ddgr_colorcxx . . $ ddgr_color# get_text_colorcxx . . $ grViewport#get_text_color(ddd8539a2fcdd4ce).() const;
529 void set_char_propertiescxx . . $ grViewport#set_char_properties(5133d185afc50666).(unsigned flags, const tCharPropertiescxx . . $ tCharProperties# *props);
530 void get_char_propertiescxx . . $ grViewport#get_char_properties(9bd9ddac0cef7fd2).(tCharPropertiescxx . . $ tCharProperties# *props) const;
531 // end
532 };
533
534 // inline definitions for grViewport functions
535
536 inline void grViewportcxx . . $ grViewport#::set_text_colorcxx . . $ grViewport#set_text_color(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# color) {
537 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[0] = color;
538 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[1] = color;
539 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[2] = color;
540 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[3] = color;
541 }
542
543 inline ddgr_colorcxx . . $ ddgr_color# grViewportcxx . . $ grViewport#::get_text_colorcxx . . $ grViewport#get_text_color(ddd8539a2fcdd4ce).() const { return char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[0]; }
544
545 inline void grViewportcxx . . $ grViewport#::set_char_propertiescxx . . $ grViewport#set_char_properties(5133d185afc50666).(unsigned flags, const tCharPropertiescxx . . $ tCharProperties# *props) {
546 if (flags & GR_VPCP_COLORcxx . . $ `2dlib/gr.h:139:9`!) {
547 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[0] = props->colcxx . . $ tCharProperties#col.[0];
548 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[1] = props->colcxx . . $ tCharProperties#col.[1];
549 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[2] = props->colcxx . . $ tCharProperties#col.[2];
550 char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[3] = props->colcxx . . $ tCharProperties#col.[3];
551 }
552 if (flags & GR_VPCP_ALPHAcxx . . $ `2dlib/gr.h:138:9`!) {
553 char_Propscxx . . $ grViewport#char_Props..alphacxx . . $ tCharProperties#alpha. = props->alphacxx . . $ tCharProperties#alpha.;
554 }
555 }
556
557 inline void grViewportcxx . . $ grViewport#::get_char_propertiescxx . . $ grViewport#get_char_properties(9bd9ddac0cef7fd2).(tCharPropertiescxx . . $ tCharProperties# *props) const {
558 props->colcxx . . $ tCharProperties#col.[0] = char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[0];
559 props->colcxx . . $ tCharProperties#col.[1] = char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[1];
560 props->colcxx . . $ tCharProperties#col.[2] = char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[2];
561 props->colcxx . . $ tCharProperties#col.[3] = char_Propscxx . . $ grViewport#char_Props..colcxx . . $ tCharProperties#col.[3];
562 props->alphacxx . . $ tCharProperties#alpha. = char_Propscxx . . $ grViewport#char_Props..alphacxx . . $ tCharProperties#alpha.;
563 }
564
565 // useful macros
566
567 static inline void VP_BITBLTcxx . . $ VP_BITBLT(811648a46ac0f615).(grViewportcxx . . $ grViewport# *vp, int dx, int dy, int bm) {
568 grMemorySurfacecxx . . $ grMemorySurface# surfcxx . . $ grMemorySurface#grMemorySurface(d4f767463ce0a6b3).(bm);
569 vp->bltcxx . . $ grViewport#blt(3c4a031b05aa6aa3).(dx, dy, &surf);
570 }
571
572 #endif