Debian Codegraph @

prboom2/src/gl_intern.h

raw
1 /* Emacs style mode select -*- C -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11 * Copyright 2005, 2006 by
12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 *
29 * DESCRIPTION:
30 *
31 *---------------------------------------------------------------------
32 */
33
34 #ifndef _GL_INTERN_H
35 #define _GL_INTERN_H
36
37 #include "v_video.h"
38 #include "xs_Float.h"
39
40 #define MAXCOORD (32767.0f / MAP_COEFF)
41
42 typedef enum
43 {
44 GLDT_UNREGISTERED,
45 GLDT_BROKEN,
46 GLDT_PATCH,
47 GLDT_TEXTURE,
48 GLDT_FLAT,
49 GLDT_COLORMAP
50 } GLTexType;
51
52 typedef enum
53 {
54 GLTEXTURE_SPRITE = 0x00000002,
55 GLTEXTURE_HASHOLES = 0x00000004,
56 GLTEXTURE_SKY = 0x00000008,
57
58
59 GLTEXTURE_CLAMPX = 0x00000040,
60 GLTEXTURE_CLAMPY = 0x00000080,
61 GLTEXTURE_CLAMPXY = (GLTEXTURE_CLAMPX | GLTEXTURE_CLAMPY),
62 GLTEXTURE_INDEXED = 0x00000100,
63 GLTEXTURE_SKYHACK = 0x00000200,
64 } GLTexture_flag_t;
65
66 typedef struct gl_strip_coords_s
67 {
68 GLfloat v[4][3];
69
70 GLfloat t[4][2];
71 } gl_strip_coords_t;
72
73 #define PLAYERCOLORMAP_COUNT (9)
74
75 typedef struct detail_s
76 {
77 GLuint texid;
78 int texture_num;
79 float width, height;
80 float offsetx, offsety;
81 } detail_t;
82
83 typedef struct color_rgb_s
84 {
85 byte r;
86 byte g;
87 byte b;
88 } color_rgb_t;
89
90 typedef struct
91 {
92 int index;
93 int patch_index;
94 int width,height;
95 int leftoffset,topoffset;
96 int tex_width,tex_height;
97 int realtexwidth, realtexheight;
98 int buffer_width,buffer_height;
99 int buffer_size;
100
101 //e6y: support for Boom colormaps
102 GLuint ***glTexExID;
103 unsigned int texflags[CR_LIMIT+MAX_MAXPLAYERS][PLAYERCOLORMAP_COUNT];
104 GLuint *texid_p;
105 unsigned int *texflags_p;
106
107 int cm;
108 int player_cm;
109
110 GLTexType textype;
111 unsigned int flags;
112 float scalexfac, scaleyfac; //e6y: right/bottom UV coordinates for patch drawing
113 } GLTexture;
114
115 typedef struct
116 {
117 float x1,x2;
118 float z1,z2;
119 dboolean fracleft, fracright; //e6y
120 } GLSeg;
121
122 typedef struct
123 {
124 GLSeg *glseg;
125 float ytop,ybottom;
126 float ul,ur,vt,vb;
127 float light;
128 float alpha;
129 float skypitch;
130 float skyyaw;
131 float skyoffset;
132 float xscale;
133 float yscale;
134 dboolean anchor_vb;
135 GLTexture *gltexture;
136 byte flag;
137 seg_t *seg;
138 } GLWall;
139
140 typedef enum
141 {
142 GLFLAT_CEILING = 0x00000001,
143 GLFLAT_HAVE_TRANSFORM = 0x00000002,
144 } GLFlat_flag_t;
145
146 typedef struct
147 {
148 int sectornum;
149 float light; // the lightlevel of the flat
150 float fogdensity;
151 float uoffs,voffs; // the texture coordinates
152 float rotation;
153 float xscale;
154 float yscale;
155 float z; // the z position of the flat (height)
156 GLTexture *gltexture;
157 unsigned int flags;
158 float alpha;
159 } GLFlat;
160
161 /* GLLoopDef is the struct for one loop. A loop is a list of vertexes
162 * for triangles, which is calculated by the gluTesselator in gld_PrecalculateSector
163 * and in gld_PreprocessCarvedFlat
164 */
165 typedef struct
166 {
167 int index; // subsector index
168 GLenum mode; // GL_TRIANGLES, GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN
169 int vertexcount; // number of vertexes in this loop
170 int vertexindex; // index into vertex list
171 } GLLoopDef;
172
173 // GLSector is the struct for a sector with a list of loops.
174
175 #define SECTOR_CLAMPXY 0x00000001
176 typedef struct
177 {
178 int loopcount; // number of loops for this sector
179 GLLoopDef *loops; // the loops itself
180 unsigned int flags;
181 } GLSector;
182
183 typedef struct
184 {
185 int loopcount; // number of loops for this sector
186 GLLoopDef *loops; // the loops itself
187 } GLMapSubsector;
188
189 typedef struct
190 {
191 GLfloat x;
192 GLfloat y;
193 GLfloat z;
194 } GLVertex;
195
196 typedef struct
197 {
198 GLfloat u;
199 GLfloat v;
200 } GLTexcoord;
201
202 typedef struct
203 {
204 GLLoopDef loop; // the loops itself
205 } GLSubSector;
206
207 typedef struct
208 {
209 float x, y, z;
210 float radius;
211 float light;
212 } GLShadow;
213
214 typedef enum
215 {
216 health_bar_null,
217 health_bar_red,
218 health_bar_yellow,
219 } health_bar_color_t;
220
221 typedef struct
222 {
223 health_bar_color_t color;
224
225 float x1, x2, x3;
226 float z1, z2, z3;
227 float y;
228 } GLHealthBar;
229
230 extern GLSeg *gl_segs;
231 extern GLSeg *gl_lines;
232
233 #define GLDWF_TOP 1
234 #define GLDWF_M1S 2
235 #define GLDWF_M2S 3
236 #define GLDWF_BOT 4
237 #define GLDWF_TOPFLUD 5 //e6y: project the ceiling plane into the gap
238 #define GLDWF_BOTFLUD 6 //e6y: project the floor plane into the gap
239 #define GLDWF_SKY 7
240 #define GLDWF_SKYFLIP 8
241
242 typedef struct
243 {
244 int cm;
245 float x,y,z;
246 float vt,vb;
247 float ul,ur;
248 float x1,y1;
249 float x2,y2;
250 float light;
251 float alpha;
252 fixed_t scale;
253 GLTexture *gltexture;
254 uint64_t flags;
255 int index;
256 int id;
257 int xy;
258 fixed_t fx,fy;
259 } GLSprite;
260
261 typedef enum
262 {
263 GLDIT_NONE,
264
265 GLDIT_WALL, // opaque wall
266 GLDIT_MWALL, // opaque mid wall
267 GLDIT_FWALL, // projected wall
268 GLDIT_TWALL, // transparent walls
269 GLDIT_SWALL, // sky walls
270
271 GLDIT_AWALL, // animated wall
272 GLDIT_FAWALL, // animated projected wall
273
274 GLDIT_CEILING, // ceiling
275 GLDIT_FLOOR, // floor
276
277 GLDIT_ACEILING, // animated ceiling
278 GLDIT_AFLOOR, // animated floor
279
280 GLDIT_SPRITE, // opaque sprite
281 GLDIT_TSPRITE, // transparent sprites
282 GLDIT_ASPRITE,
283
284 GLDIT_SHADOW,
285
286 GLDIT_HBAR,
287
288 GLDIT_TYPES
289 } GLDrawItemType;
290
291 typedef struct GLDrawItem_s
292 {
293 union
294 {
295 void *item;
296 GLWall *wall;
297 GLFlat *flat;
298 GLSprite *sprite;
299 GLShadow *shadow;
300 GLHealthBar *hbar;
301 } item;
302 } GLDrawItem;
303
304 typedef struct GLDrawDataItem_s
305 {
306 byte *data;
307 int maxsize;
308 int size;
309 } GLDrawDataItem_t;
310
311 typedef struct
312 {
313 GLDrawDataItem_t *data;
314 int maxsize;
315 int size;
316
317 GLDrawItem *items[GLDIT_TYPES];
318 int num_items[GLDIT_TYPES];
319 int max_items[GLDIT_TYPES];
320 } GLDrawInfo;
321
322 void gld_AddDrawItem(GLDrawItemType itemtype, void *itemdata);
323
324 void gld_DrawTriangleStrip(GLWall *wall, gl_strip_coords_t *c);
325
326 extern float roll;
327 extern float yaw;
328 extern float inv_yaw;
329 extern float pitch;
330
331 extern int gl_preprocessed; //e6y
332
333 extern GLDrawInfo gld_drawinfo;
334 void gld_FreeDrawInfo(void);
335 void gld_ResetDrawInfo(void);
336
337 extern GLSector *sectorloops;
338 extern GLMapSubsector *subsectorloops;
339
340 extern GLfloat gl_texture_filter_anisotropic;
341 void gld_SetTexFilters(GLTexture *gltexture);
342
343 extern float xCamera,yCamera,zCamera;
344
345 //
346 //detail
347 //
348
349 void gld_InitDetail(void);
350
351 void gld_PreprocessDetail(void);
352
353 extern GLuint* last_glTexID;
354 GLTexture *gld_RegisterTexture(int texture_num, dboolean mipmap, dboolean force, dboolean indexed, dboolean sky);
355 void gld_BindTexture(GLTexture *gltexture, unsigned int flags, dboolean sky);
356 GLTexture *gld_RegisterPatch(int lump, int cm, dboolean is_sprite, dboolean indexed);
357 void gld_BindPatch(GLTexture *gltexture, int cm);
358 GLTexture *gld_RegisterRaw(int lump, int width, int height, dboolean mipmap, dboolean indexed);
359 void gld_BindRaw(GLTexture *gltexture, unsigned int flags);
360 #define gld_RegisterFlat(lump, mipmap, indexed) \
361 gld_RegisterRaw((firstflat+lump), 64, 64, (mipmap), (indexed))
362 #define gld_BindFlat(gltexture, flags) \
363 gld_BindRaw((gltexture), (flags))
364 GLTexture *gld_RegisterSkyTexture(int texture_num, dboolean force);
365 void gld_BindSkyTexture(GLTexture *gltexture);
366 GLTexture *gld_RegisterColormapTexture(int palette_index, int gamma_level, dboolean fullbright);
367 void gld_BindColormapTexture(GLTexture *gltexture, int palette_index, int gamma_level, dboolean fullbright);
368 void gld_InitColormapTextures(dboolean fullbright);
369 void gld_InitFuzzTexture(void);
370 int gld_GetTexDimension(int value);
371 void gld_SetIndexedPalette(int palette_index);
372 void gld_Precache(void);
373
374 void SetFrameTextureMode(void);
375
376 //gl_vertex
377 void gld_SplitLeftEdge(const GLWall *wall);
378 void gld_SplitRightEdge(const GLWall *wall);
379 void gld_RecalcVertexHeights(const vertex_t *v);
380
381 //e6y
382 void gld_InitGLVersion(void);
383 void gld_ResetLastTexture(void);
384
385 unsigned char* gld_GetTextureBuffer(GLuint texid, int miplevel, int *width, int *height);
386
387 int gld_BuildTexture(GLTexture *gltexture, void *data, dboolean readonly, int width, int height);
388
389 GLuint CaptureScreenAsTexID(void);
390
391 //progress
392 void gld_ProgressUpdate(const char * text, int progress, int total);
393 int gld_ProgressStart(void);
394 int gld_ProgressEnd(void);
395
396 //FBO
397 extern GLuint glSceneImageFBOTexID;
398 extern GLuint glSceneImageTextureFBOTexID;
399
400 extern dboolean invul_cm;
401 extern float bw_red;
402 extern float bw_green;
403 extern float bw_blue;
404 extern int SceneInTexture;
405 void gld_InitFBO(void);
406 void gld_FreeScreenSizeFBO(void);
407
408 extern int imageformats[];
409
410 //missing flats (fake floors and ceilings)
411
412 void gld_PreprocessFakeSectors(void);
413
414 void gld_SetupFloodStencil(GLWall *wall);
415 void gld_ClearFloodStencil(GLWall *wall);
416
417 void gld_SetupFloodedPlaneCoords(GLWall *wall, gl_strip_coords_t *c);
418 void gld_SetupFloodedPlaneLight(GLWall *wall);
419
420 //light
421 void gld_StaticLightAlpha(float light, float alpha);
422 #define gld_StaticLight(light) gld_StaticLightAlpha(light, 1.0f)
423 void gld_InitLightTable(void);
424 int gld_GetGunFlashLight(void);
425
426 float gld_CalcLightLevel(int lightlevel);
427 float gld_Calc2DLightLevel(int lightlevel);
428
429 // SkyBox
430 #define SKY_NONE 0
431 #define SKY_CEILING 1
432 #define SKY_FLOOR 2
433 typedef struct PalEntry_s
434 {
435 unsigned char r, g, b;
436 } PalEntry_t;
437 typedef struct SkyBoxParams_s
438 {
439 int index;
440 unsigned int type;
441 GLWall wall;
442 float x_offset, y_offset;
443 // 0 - no colormap; 1 - INVUL inverse colormap
444 PalEntry_t FloorSkyColor[2];
445 PalEntry_t CeilingSkyColor[2];
446 } SkyBoxParams_t;
447 extern SkyBoxParams_t SkyBox;
448 extern GLfloat gl_whitecolor[];
449 void gld_InitSky(void);
450 void gld_AddSkyTexture(GLWall *wall, int sky1, int sky2, int skytype);
451 void gld_GetSkyCapColors(void);
452 void gld_InitFrameSky(void);
453 void gld_DrawStripsSky(void);
454 void gld_DrawScreenSkybox(void);
455 void gld_GetScreenSkyScale(GLWall *wall, float *scale_x, float *scale_y);
456 void gld_DrawDomeSkyBox(void);
457 void gld_DrawSkyCaps(void);
458
459 // VBO
460 typedef struct vbo_vertex_s
461 {
462 float x, y, z;
463 float u, v;
464 unsigned char r, g, b, a;
465 } PACKEDATTR vbo_vertex_t;
466 #define NULL_VBO_VERTEX ((vbo_vertex_t*)NULL)
467 #define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &vbo->data[0].x)
468 #define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &vbo->data[0].u)
469 #define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &vbo->data[0].r)
470
471 typedef struct vbo_xyz_uv_s
472 {
473 float x, y, z;
474 float u, v;
475 } PACKEDATTR vbo_xyz_uv_t;
476 extern vbo_xyz_uv_t *flats_vbo;
477 #define NULL_VBO_XYZ_UV ((vbo_xyz_uv_t*)NULL)
478 #define flats_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_XYZ_UV->x : &flats_vbo[0].x)
479 #define flats_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_XYZ_UV->u : &flats_vbo[0].u)
480
481 typedef struct vbo_xy_uv_rgba_s
482 {
483 float x, y;
484 float u, v;
485 unsigned char r, g, b, a;
486 } PACKEDATTR vbo_xy_uv_rgba_t;
487
488 // preprocessing
489 extern byte *segrendered; // true if sector rendered (only here for malloc)
490 extern int *linerendered[2]; // true if linedef rendered (only here for malloc)
491 extern int rendermarker;
492 extern GLuint flats_vbo_id;
493
494 void glsl_Init(void);
495 void glsl_SetTextureDims(int unit, unsigned int width, unsigned int height);
496 void glsl_PushNullShader(void);
497 void glsl_PopNullShader(void);
498 void glsl_PushMainShader(void);
499 void glsl_PopMainShader(void);
500 void glsl_PushFuzzShader(int tic, int sprite, float ratio);
501 void glsl_PopFuzzShader(void);
502 void glsl_SetLightLevel(float lightlevel);
503
504 #endif // _GL_INTERN_H