/
r_data.h
346 lines (286 loc) · 10.9 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
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2008 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2008 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
*/
/**
* r_data.h: Data Structures For Refresh
*/
#ifndef __DOOMSDAY_REFRESH_DATA_H__
#define __DOOMSDAY_REFRESH_DATA_H__
#include "gl_main.h"
#include "dd_def.h"
#include "p_think.h"
#include "m_nodepile.h"
#include "def_data.h"
#include "r_extres.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 materialtexinst_s {
DGLuint tex; // Name of the associated DGL texture.
byte masked;
float color[3]; // Average color (for lighting).
float topColor[3]; // Averaged top line color, used for sky fadeouts.
} materialtexinst_t;
// Detail texture instance.
typedef struct detailtexinst_s {
DGLuint tex;
float contrast;
struct detailtexinst_s* next;
} detailtexinst_t;
typedef struct {
int width, height;
float strength;
float scale;
float maxDist;
lumpnum_t lump;
const char* external;
// Linked list of detail texture instances.
// A unique texture is generated for each (rounded) contrast level.
detailtexinst_t* instances;
} detailtex_t;
// Flags for gltexture_t:
#define GLTXF_MASKED 0x00000001
typedef struct gltexture_s {
DGLuint id;
int flags; // GLTXF_* flags.
int magMode;
float width, height;
float scale; // Currently only used with detail textures.
} gltexture_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;
// This is the dummy mobj_t used for blockring roots.
// It has some excess information since it has to be compatible with
// regular mobjs (otherwise the rings don't really work).
// Note: the thinker and pos data could be used for something else...
typedef struct linkmobj_s {
thinker_t thinker;
float pos[3];
struct mobj_s* bNext, *bPrev;
} linkmobj_t;
typedef struct shadowlink_s {
struct shadowlink_s* next;
linedef_t* lineDef;
byte side;
} shadowlink_t;
typedef struct subplaneinfo_s {
vertexillum_t* illum;
biastracker_t tracker;
uint updated;
biasaffection_t affected[MAX_BIAS_AFFECTED];
} subplaneinfo_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 0x1 // Not to be drawn.
#define TXDF_IWAD 0x2 // 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;
byte flags;
short patchCount;
texpatch_t patches[1]; // [patchcount] drawn back to front into the cached texture.
} texturedef_t;
typedef struct flat_s {
lumpnum_t lump;
} flat_t;
typedef struct {
lumpnum_t lump; // Real lump number.
short width, height, offX, offY;
float flareX, flareY, lumSize;
rgbcol_t autoLightColor;
float texCoord[2]; // Prepared texture coordinates.
DGLuint pspriteTex;
} spritetex_t;
// A translated sprite.
typedef struct {
int patch;
DGLuint tex;
unsigned char* table;
float flareX, flareY, lumSize;
rgbcol_t autoLightColor;
} transspr_t;
// Model skin.
typedef struct {
char path[256];
DGLuint tex;
} skintex_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;
short offX, offY;
short extraOffset[2]; // Only used with upscaled and sharpened patches.
int flags; // Possible modifier filters to apply (monochrome, scale+sharp)
// Part 1
DGLuint tex; // Name of the associated DGL texture.
short width, height;
// Part 2 (only used with textures larger than the max texture size).
DGLuint tex2;
short width2, height2;
struct patchtex_s* next;
} patchtex_t;
// A rawtex is a lump raw graphic that has been prepared for render.
typedef struct rawtex_s {
lumpnum_t lump;
// Part 1
DGLuint tex; // Name of the associated DGL texture.
short width, height;
byte masked;
// Part 2 (only used with textures larger than the max texture size).
DGLuint tex2;
short width2, height2;
byte masked2;
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_FLARE, // (flare)
FXT_BRFLARE, // (brFlare)
FXT_BIGFLARE, // (bigFlare)
NUM_FLARE_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 linkmobj_t* blockrings;
extern byte* rejectMatrix; // For fast sight rejection.
extern nodepile_t* mobjNodes, *lineNodes;
extern int viewwidth, viewheight;
extern int levelFullBright;
extern int glowingTextures;
extern byte precacheSprites, precacheSkins;
extern int numFlats;
extern flat_t** flats;
extern spritetex_t** spriteTextures;
extern int numSpriteTextures;
extern detailtex_t** detailTextures;
extern int numDetailTextures;
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_InitData(void);
void R_UpdateData(void);
void R_ShutdownData(void);
void R_UpdateSector(struct sector_s* sec, boolean forceUpdate);
void R_PrecacheMap(void);
void R_PrecachePatch(lumpnum_t lump);
texturedef_t* R_GetTextureDef(int num);
int R_NewSpriteTexture(lumpnum_t lump, struct material_s** mat);
int R_GetSkinTexIndex(const char* skin);
skintex_t* R_GetSkinTexByIndex(int id);
int R_RegisterSkin(char* skin, const char* modelfn, char* fullpath);
void R_DeleteSkinTextures(void);
void R_DestroySkins(void); // Called at shutdown.
void R_InitAnimGroup(ded_group_t* def);
void R_CreateDetailTexture(ded_detailtexture_t* def);
detailtex_t* R_GetDetailTexture(lumpnum_t lump, const char* external,
float scale, float strength, float maxDist);
void R_DeleteDetailTextures(void);
void R_DestroyDetailTextures(void); // Called at shutdown.
patchtex_t* R_FindPatchTex(lumpnum_t lump); // May return NULL.
patchtex_t* R_GetPatchTex(lumpnum_t lump); // Creates new entries.
patchtex_t** R_CollectPatchTexs(int* count);
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, struct material_s* mat,
boolean hasExternal);
boolean R_IsAllowedReflection(ded_reflection_t* def, struct material_s* mat,
boolean hasExternal);
boolean R_IsAllowedDetailTex(ded_detailtexture_t* def, struct material_s* mat,
boolean hasExternal);
boolean R_IsValidLightDecoration(const ded_decorlight_t* lightDef);
#endif