Debian Codegraph @

lib/lightmap.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
19 #ifndef LIGHTMAP_H
20 #define LIGHTMAP_H
21
22 #include "pstypes.h"
23
24 #define MAX_LIGHTMAPS (65534)
25 #define BAD_LM_INDEX 65535
26
27 // lightmap flags
28 #define LF_CHANGED 1 // this bitmap has changed since last frame (useful for hardware cacheing)
29 #define LF_LIMITS 2 // This lightmap has a specific area that has changed since last frame
30 #define LF_WRAP 4 // This lightmap should be drawn with wrapping (not clamping)
31 #define LF_BRAND_NEW 8 // This lightmap is brand new and hasn't been to the video card yet
32
33 struct bms_lightmap {
34 uint8_t width, height; // Width and height in pixels
35 uint16_t *data; // 16bit data
36
37 uint16_t used;
38 uint8_t flags;
39 int16_t cache_slot; // for the renderers use
40 uint8_t square_res; // for renderers use
41 uint8_t cx1, cy1, cx2, cy2; // Change x and y coords
42 };
43
44 extern bms_lightmap GameLightmaps[MAX_LIGHTMAPS];
45
46 // Sets all the lightmaps to unused
47 void lm_InitLightmaps();
48
49 void lm_ShutdownLightmaps(void);
50
51 // Allocs a lightmap of w x h size
52 // Returns lightmap handle if successful, -1 if otherwise
53 int lm_AllocLightmap(int w, int h);
54
55 // Given a handle, frees the lightmap memory and flags this lightmap as unused
56 void lm_FreeLightmap(int handle);
57
58 // returns a lightmaps width else -1 if something is wrong
59 int lm_w(int handle);
60
61 // returns a lightmaps height , else -1 if something is wrong
62 int lm_h(int handle);
63
64 // returns a lightmaps data else NULL if something is wrong
65 uint16_t *lm_data(int handle);
66
67 #endif