/
r_data.h
370 lines (302 loc) · 12 KB
/
r_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/**\file r_data.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* Data structures for refresh.
*/
#ifndef LIBDENG_REFRESH_DATA_H
#define LIBDENG_REFRESH_DATA_H
#include "gl_main.h"
#include "dd_def.h"
#include "p_think.h"
#include "m_nodepile.h"
#include "def_data.h"
// Flags for material decorations.
#define DCRF_NO_IWAD 0x1 // Don't use if from IWAD.
#define DCRF_PWAD 0x2 // Can use if from PWAD.
#define DCRF_EXTERNAL 0x4 // Can use if from external resource.
// Flags for material reflections.
#define REFF_NO_IWAD 0x1 // Don't use if from IWAD.
#define REFF_PWAD 0x2 // Can use if from PWAD.
#define REFF_EXTERNAL 0x4 // Can use if from external resource.
// Flags for material detailtexs.
#define DTLF_NO_IWAD 0x1 // Don't use if from IWAD.
#define DTLF_PWAD 0x2 // Can use if from PWAD.
#define DTLF_EXTERNAL 0x4 // Can use if from external resource.
typedef struct detailtex_s {
gltextureid_t id;
boolean isExternal;
const dduri_t* filePath;
} detailtex_t;
typedef struct lightmap_s {
gltextureid_t id;
const dduri_t* external;
} lightmap_t;
typedef struct flaretex_s {
gltextureid_t id;
const dduri_t* external;
} flaretex_t;
typedef struct shinytex_s {
gltextureid_t id;
const dduri_t* external;
} shinytex_t;
typedef struct masktex_s {
gltextureid_t id;
const dduri_t* external;
short width, height;
} masktex_t;
typedef enum {
TU_PRIMARY = 0,
TU_PRIMARY_DETAIL,
TU_INTER,
TU_INTER_DETAIL,
NUM_TEXMAP_UNITS
} gltexunit_t;
typedef struct glcommand_vertex_s {
float s, t;
int index;
} glcommand_vertex_t;
#define RL_MAX_DIVS 64
typedef struct walldiv_s {
unsigned int num;
float pos[RL_MAX_DIVS];
} walldiv_t;
typedef struct rvertex_s {
float pos[3];
} rvertex_t;
typedef struct rcolor_s {
float rgba[4];
} rcolor_t;
typedef struct rtexcoord_s {
float st[2];
} rtexcoord_t;
typedef struct shadowlink_s {
struct shadowlink_s* next;
linedef_t* lineDef;
byte side;
} shadowlink_t;
typedef float colorcomp_t;
typedef colorcomp_t rgbcol_t[3];
typedef colorcomp_t rgbacol_t[4];
typedef struct {
lumpnum_t lump;
short offX; // block origin (allways UL), which has allready
short offY; // accounted for the patch's internal origin
} texpatch_t;
#define TXDF_NODRAW 0x0001 // Not to be drawn.
#define TXDF_IWAD 0x0002 // Defines an IWAD texture. Note the definition may NOT be from the IWAD.
// Describes a rectangular texture, which is composed of one
// or more texpatch_t structures that arrange graphic patches.
typedef struct {
char name[9];
short width, height;
short flags;
short patchCount;
texpatch_t patches[1]; // [patchcount] drawn back to front into the cached texture.
} doomtexturedef_t;
typedef struct flat_s {
lumpname_t name;
boolean isCustom;
} flat_t;
typedef struct {
lumpnum_t lump; // Real lump number.
short width, height, offX, offY;
} spritetex_t;
// Model skin.
typedef struct {
filename_t path;
gltextureid_t id;
} skinname_t;
// Patch flags.
#define PF_MONOCHROME 0x1
#define PF_UPSCALE_AND_SHARPEN 0x2
// A patchtex is a lumppatch that has been prepared for render.
typedef struct patchtex_s {
lumpnum_t lump;
gltextureid_t texId; // Name of the associated GL texture.
boolean isCustom;
short flags;
short width, height;
short offX, offY;
} patchtex_t;
typedef struct lumppatch_s {
short width; // Bounding box size.
short height;
short leftOffset; // Pixels to the left of origin.
short topOffset; // Pixels below the origin.
int columnOfs[8]; // Only [width] used the [0] is &columnofs[width]
} lumppatch_t;
// A rawtex is a lump raw graphic that has been prepared for render.
typedef struct rawtex_s {
lumpnum_t lump;
DGLuint tex; // Name of the associated DGL texture.
short width, height;
byte masked;
struct rawtex_s* next;
} rawtex_t;
typedef struct {
float approxDist; // Only an approximation.
float vector[3]; // Light direction vector.
float color[3]; // How intense the light is (0..1, RGB).
float offset;
float lightSide, darkSide; // Factors for world light.
boolean affectedByAmbient;
} vlight_t;
/**
* Textures used in the lighting system.
*/
typedef enum lightingtexid_e {
LST_DYNAMIC, // Round dynamic light
LST_GRADIENT, // Top-down gradient
LST_RADIO_CO, // FakeRadio closed/open corner shadow
LST_RADIO_CC, // FakeRadio closed/closed corner shadow
LST_RADIO_OO, // FakeRadio open/open shadow
LST_RADIO_OE, // FakeRadio open/edge shadow
NUM_LIGHTING_TEXTURES
} lightingtexid_t;
typedef enum flaretexid_e {
FXT_ROUND,
FXT_FLARE, // (flare)
FXT_BRFLARE, // (brFlare)
FXT_BIGFLARE, // (bigFlare)
NUM_SYSFLARE_TEXTURES
} flaretexid_t;
/**
* Textures used in world rendering.
* eg a surface with a missing tex/flat is drawn using the "missing" graphic
*/
typedef enum ddtextureid_e {
DDT_UNKNOWN, // Drawn if a texture/flat is unknown
DDT_MISSING, // Drawn in place of HOMs in dev mode.
DDT_BBOX, // Drawn when rendering bounding boxes
DDT_GRAY, // For lighting debug.
NUM_DD_TEXTURES
} ddtextureid_t;
typedef struct {
DGLuint tex;
} ddtexture_t;
extern nodeindex_t* linelinks;
extern blockmap_t* BlockMap;
extern blockmap_t* SSecBlockMap;
extern nodepile_t* mobjNodes, *lineNodes;
extern int viewwidth, viewheight;
extern int levelFullBright;
extern float glowingTextures;
extern byte precacheSprites, precacheSkins;
extern spritetex_t** spriteTextures;
extern int numSpriteTextures;
extern detailtex_t** detailTextures;
extern int numDetailTextures;
extern lightmap_t** lightMaps;
extern int numLightMaps;
extern flaretex_t** flareTextures;
extern int numFlareTextures;
extern shinytex_t** shinyTextures;
extern int numShinyTextures;
extern masktex_t** maskTextures;
extern int numMaskTextures;
extern uint numSkinNames;
extern skinname_t* skinNames;
void R_InitRendVerticesPool(void);
rvertex_t* R_AllocRendVertices(uint num);
rcolor_t* R_AllocRendColors(uint num);
rtexcoord_t* R_AllocRendTexCoords(uint num);
void R_FreeRendVertices(rvertex_t* rvertices);
void R_FreeRendColors(rcolor_t* rcolors);
void R_FreeRendTexCoords(rtexcoord_t* rtexcoords);
void R_InfoRendVerticesPool(void);
void R_DivVerts(rvertex_t* dst, const rvertex_t* src,
const walldiv_t* divs);
void R_DivVertColors(rcolor_t* dst, const rcolor_t* src,
const walldiv_t* divs, float bL, float tL,
float bR, float tR);
void R_DivTexCoords(rtexcoord_t* dst, const rtexcoord_t* src,
const walldiv_t* divs, float bL, float tL,
float bR, float tR);
void R_UpdateTexturesAndFlats(void);
void R_InitSystemTextures(void);
void R_InitTextures(void);
void R_InitFlats(void);
/// @return Flat associated to index# @a idx
flat_t* R_GetFlatForIdx(int idx);
void R_UpdateData(void);
void R_ShutdownData(void);
colorpaletteid_t R_CreateColorPalette(const char* fmt, const char* name,
const byte* data, ushort num);
const char* R_GetColorPaletteNameForNum(colorpaletteid_t id);
colorpaletteid_t R_GetColorPaletteNumForName(const char* name);
DGLuint R_GetColorPalette(colorpaletteid_t id);
void R_GetColorPaletteRGBf(colorpaletteid_t id, float rgb[3],
int idx, boolean correctGamma);
boolean R_SetDefaultColorPalette(colorpaletteid_t id);
//boolean R_UpdateSubSector(struct subsector_t* ssec, boolean forceUpdate);
boolean R_UpdateSector(struct sector_s* sec, boolean forceUpdate);
boolean R_UpdateLinedef(struct linedef_s* line, boolean forceUpdate);
boolean R_UpdateSidedef(struct sidedef_s* side, boolean forceUpdate);
boolean R_UpdatePlane(struct plane_s* pln, boolean forceUpdate);
boolean R_UpdateSurface(struct surface_s* suf, boolean forceUpdate);
void R_PrecacheMap(void);
void R_PrecacheMobjNum(int mobjtypeNum);
doomtexturedef_t* R_GetDoomTextureDef(int num);
uint R_GetSkinNumForName(const char* path);
const skinname_t* R_GetSkinNameByIndex(uint id);
uint R_RegisterSkin(ddstring_t* foundPath, const char* skin, const char* modelfn, boolean isShinySkin);
void R_DestroySkins(void); // Called at shutdown.
boolean R_DrawVLightVector(const vlight_t* light, void* context);
void R_InitAnimGroup(ded_group_t* def);
detailtex_t* R_CreateDetailTexture(const ded_detailtexture_t* def);
detailtex_t* R_GetDetailTexture(const dduri_t* filePath, boolean isExternal);
void R_DestroyDetailTextures(void); // Called at shutdown.
lightmap_t* R_CreateLightMap(const dduri_t* uri);
lightmap_t* R_GetLightMap(const dduri_t* uri);
void R_DestroyLightMaps(void); // Called at shutdown.
flaretex_t* R_CreateFlareTexture(const dduri_t* uri);
flaretex_t* R_GetFlareTexture(const dduri_t* uri);
void R_DestroyFlareTextures(void); // Called at shutdown.
shinytex_t* R_CreateShinyTexture(const dduri_t* uri);
shinytex_t* R_GetShinyTexture(const dduri_t* uri);
void R_DestroyShinyTextures(void); // Called at shutdown.
masktex_t* R_CreateMaskTexture(const dduri_t* uri, short width, short height);
masktex_t* R_GetMaskTexture(const dduri_t* uri);
void R_DestroyMaskTextures(void); // Called at shutdown.
patchid_t R_PrecachePatch(const char* name, patchinfo_t* info);
patchid_t R_RegisterAsPatch(const char* name);
patchtex_t* R_FindPatchTex(patchid_t id);
void R_ClearPatchTexs(void);
boolean R_GetPatchInfo(patchid_t id, patchinfo_t* info);
void R_InitRawTexs(void);
void R_UpdateRawTexs(void);
rawtex_t* R_FindRawTex(lumpnum_t lump); // May return NULL.
rawtex_t* R_GetRawTex(lumpnum_t lump); // Creates new entries.
rawtex_t** R_CollectRawTexs(int* count);
boolean R_IsAllowedDecoration(ded_decor_t* def, material_t* mat,
boolean hasExternal);
boolean R_IsAllowedReflection(ded_reflection_t* def, material_t* mat,
boolean hasExternal);
boolean R_IsAllowedDetailTex(ded_detailtexture_t* def, material_t* mat,
boolean hasExternal);
boolean R_IsValidLightDecoration(const ded_decorlight_t* lightDef);
void R_InitVectorGraphics(void);
void R_UnloadVectorGraphics(void);
void R_ShutdownVectorGraphics(void);
#endif /* LIBDENG_REFRESH_DATA_H */