]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - render.h
Merge PR 'Use the text from modinfo.txt as the mod menu entry'
[xonotic/darkplaces.git] / render.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the 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, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #ifndef RENDER_H
22 #define RENDER_H
23
24 #include "svbsp.h"
25 #include "r_stats.h"
26
27 typedef enum glsl_attrib_e
28 {
29         GLSLATTRIB_POSITION = 0,
30         GLSLATTRIB_COLOR = 1,
31         GLSLATTRIB_TEXCOORD0 = 2,
32         GLSLATTRIB_TEXCOORD1 = 3,
33         GLSLATTRIB_TEXCOORD2 = 4,
34         GLSLATTRIB_TEXCOORD3 = 5,
35         GLSLATTRIB_TEXCOORD4 = 6,
36         GLSLATTRIB_TEXCOORD5 = 7,
37         GLSLATTRIB_TEXCOORD6 = 8,
38         GLSLATTRIB_TEXCOORD7 = 9,
39 }
40 glsl_attrib;
41
42 typedef enum shaderlanguage_e
43 {
44         SHADERLANGUAGE_GLSL,
45         SHADERLANGUAGE_COUNT
46 }
47 shaderlanguage_t;
48
49 /// this enum selects which of the glslshadermodeinfo entries should be used
50 typedef enum shadermode_e
51 {
52         SHADERMODE_GENERIC, ///< (particles/HUD/etc) vertex color, optionally multiplied by one texture
53         SHADERMODE_POSTPROCESS, ///< postprocessing shader (r_glsl_postprocess)
54         SHADERMODE_DEPTH_OR_SHADOW, ///< (depthfirst/shadows) vertex shader only
55         SHADERMODE_FLATCOLOR, ///< (lightmap) modulate texture by uniform color (q1bsp, q3bsp)
56         SHADERMODE_VERTEXCOLOR, ///< (lightmap) modulate texture by vertex colors (q3bsp)
57         SHADERMODE_LIGHTMAP, ///< (lightmap) modulate texture by lightmap texture (q1bsp, q3bsp)
58         SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE, ///< (lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp deluxemap)
59         SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE, ///< (lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp deluxemap)
60         SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP, // forced deluxemapping for lightmapped surfaces
61         SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR, // forced deluxemapping for vertexlit surfaces
62         SHADERMODE_LIGHTGRID, ///< (lightmap) use directional pixel shading from lightgrid data (q3bsp)
63         SHADERMODE_LIGHTDIRECTION, ///< (lightmap) use directional pixel shading from fixed light direction (q3bsp)
64         SHADERMODE_LIGHTSOURCE, ///< (lightsource) use directional pixel shading from light source (rtlight)
65         SHADERMODE_REFRACTION, ///< refract background (the material is rendered normally after this pass)
66         SHADERMODE_WATER, ///< refract background and reflection (the material is rendered normally after this pass)
67         SHADERMODE_DEFERREDGEOMETRY, ///< (deferred) render material properties to screenspace geometry buffers
68         SHADERMODE_DEFERREDLIGHTSOURCE, ///< (deferred) use directional pixel shading from light source (rtlight) on screenspace geometry buffers
69         SHADERMODE_COUNT
70 }
71 shadermode_t;
72
73 #define SHADERPERMUTATION_DIFFUSE (1u<<0) ///< (lightsource) whether to use directional shading
74 #define SHADERPERMUTATION_VERTEXTEXTUREBLEND (1u<<1) ///< indicates this is a two-layer material blend based on vertex alpha (q3bsp)
75 #define SHADERPERMUTATION_VIEWTINT (1u<<2) ///< view tint (postprocessing only), use vertex colors (generic only)
76 #define SHADERPERMUTATION_COLORMAPPING (1u<<3) ///< indicates this is a colormapped skin
77 #define SHADERPERMUTATION_SATURATION (1u<<4) ///< saturation (postprocessing only)
78 #define SHADERPERMUTATION_FOGINSIDE (1u<<5) ///< tint the color by fog color or black if using additive blend mode
79 #define SHADERPERMUTATION_FOGOUTSIDE (1u<<6) ///< tint the color by fog color or black if using additive blend mode
80 #define SHADERPERMUTATION_FOGHEIGHTTEXTURE (1u<<7) ///< fog color and density determined by texture mapped on vertical axis
81 #define SHADERPERMUTATION_FOGALPHAHACK (1u<<8) ///< fog color and density determined by texture mapped on vertical axis
82 #define SHADERPERMUTATION_GAMMARAMPS (1u<<9) ///< gamma (postprocessing only)
83 #define SHADERPERMUTATION_CUBEFILTER (1u<<10) ///< (lightsource) use cubemap light filter
84 #define SHADERPERMUTATION_GLOW (1u<<11) ///< (lightmap) blend in an additive glow texture
85 #define SHADERPERMUTATION_BLOOM (1u<<12) ///< bloom (postprocessing only)
86 #define SHADERPERMUTATION_SPECULAR (1u<<13) ///< (lightsource or deluxemapping) render specular effects
87 #define SHADERPERMUTATION_POSTPROCESSING (1u<<14) ///< user defined postprocessing (postprocessing only)
88 #define SHADERPERMUTATION_REFLECTION (1u<<15) ///< normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the surface
89 #define SHADERPERMUTATION_OFFSETMAPPING (1u<<16) ///< adjust texcoords to roughly simulate a displacement mapped surface
90 #define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING (1u<<17) ///< adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!)
91 #define SHADERPERMUTATION_SHADOWMAP2D (1u<<18) ///< (lightsource) use shadowmap texture as light filter
92 #define SHADERPERMUTATION_SHADOWMAPVSDCT (1u<<19) ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing
93 #define SHADERPERMUTATION_SHADOWMAPORTHO (1u<<20) ///< (lightsource) use orthographic shadowmap projection
94 #define SHADERPERMUTATION_DEFERREDLIGHTMAP (1u<<21) ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
95 #define SHADERPERMUTATION_ALPHAKILL (1u<<22) ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha
96 #define SHADERPERMUTATION_REFLECTCUBE (1u<<23) ///< fake reflections using global cubemap (not HDRI light probe)
97 #define SHADERPERMUTATION_NORMALMAPSCROLLBLEND (1u<<24) ///< (water) counter-direction normalmaps scrolling
98 #define SHADERPERMUTATION_BOUNCEGRID (1u<<25) ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light
99 #define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL (1u<<26) ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component
100 #define SHADERPERMUTATION_TRIPPY (1u<<27) ///< use trippy vertex shader effect
101 #define SHADERPERMUTATION_DEPTHRGB (1u<<28) ///< read/write depth values in RGB color coded format for older hardware without depth samplers
102 #define SHADERPERMUTATION_ALPHAGEN_VERTEX (1u<<29) ///< alphaGen vertex
103 #define SHADERPERMUTATION_SKELETAL (1u<<30) ///< (skeletal models) use skeletal matrices to deform vertices (gpu-skinning)
104 #define SHADERPERMUTATION_OCCLUDE (1u<<31) ///< use occlusion buffer for corona
105 #define SHADERPERMUTATION_COUNT 32u ///< size of shaderpermutationinfo array
106 // UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86.
107
108 // 1.0f / N table
109 extern float ixtable[4096];
110
111 // fog stuff
112 void FOG_clear(void);
113
114 // sky stuff
115 extern cvar_t r_sky;
116 extern cvar_t r_skyscroll1;
117 extern cvar_t r_skyscroll2;
118 extern cvar_t r_sky_scissor;
119 extern cvar_t r_q3bsp_renderskydepth;
120 extern int skyrenderlater, skyrendermasked;
121 extern int skyscissor[4];
122 int R_SetSkyBox(const char *sky);
123 void R_SkyStartFrame(void);
124 void R_Sky(void);
125 void R_ResetSkyBox(void);
126
127 // SHOWLMP stuff (Nehahra)
128 void SHOWLMP_decodehide(void);
129 void SHOWLMP_decodeshow(void);
130 void SHOWLMP_drawall(void);
131
132 // render profiling stuff
133 extern int r_timereport_active;
134
135 // lighting stuff
136 extern cvar_t r_ambient;
137 extern cvar_t gl_flashblend;
138
139 // vis stuff
140 extern cvar_t r_novis;
141
142 extern cvar_t r_trippy;
143 extern cvar_t r_fxaa;
144
145 extern cvar_t r_lerpsprites;
146 extern cvar_t r_lerpmodels;
147 extern cvar_t r_lerplightstyles;
148 extern cvar_t r_waterscroll;
149
150 extern cvar_t developer_texturelogging;
151
152 // shadow volume bsp struct with automatically growing nodes buffer
153 extern svbsp_t r_svbsp;
154
155 typedef struct rmesh_s
156 {
157         // vertices of this mesh
158         int maxvertices;
159         int numvertices;
160         float *vertex3f;
161         float *svector3f;
162         float *tvector3f;
163         float *normal3f;
164         float *texcoord2f;
165         float *texcoordlightmap2f;
166         float *color4f;
167         // triangles of this mesh
168         int maxtriangles;
169         int numtriangles;
170         int *element3i;
171         // snapping epsilon
172         float epsilon2;
173 }
174 rmesh_t;
175
176 // useful functions for rendering
177 void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b);
178 void R_FillColors(float *out, int verts, float r, float g, float b, float a);
179 void R_Mesh_AddPolygon3f(rmesh_t *mesh, int numvertices, float *vertex3f);
180 void R_Mesh_AddBrushMeshFromPlanes(rmesh_t *mesh, int numplanes, mplane_t *planes);
181
182 #define TOP_RANGE               16                      // soldier uniform colors
183 #define BOTTOM_RANGE    96
184
185 //=============================================================================
186
187 extern cvar_t r_nearclip;
188
189 // forces all rendering to draw triangle outlines
190 extern cvar_t r_showoverdraw;
191 extern cvar_t r_showtris;
192 extern cvar_t r_shownormals;
193 extern cvar_t r_showlighting;
194 extern cvar_t r_showcollisionbrushes;
195 extern cvar_t r_showcollisionbrushes_polygonfactor;
196 extern cvar_t r_showcollisionbrushes_polygonoffset;
197 extern cvar_t r_showdisabledepthtest;
198
199 extern cvar_t r_drawentities;
200 extern cvar_t r_draw2d;
201 extern qbool r_draw2d_force;
202 extern cvar_t r_drawviewmodel;
203 extern cvar_t r_drawworld;
204 extern cvar_t r_speeds;
205 extern cvar_t r_fullbright;
206 extern cvar_t r_wateralpha;
207 extern cvar_t r_dynamic;
208
209 extern cvar_t r_q1bsp_lightmap_updates_enabled;
210 extern cvar_t r_q1bsp_lightmap_updates_combine;
211 extern cvar_t r_q1bsp_lightmap_updates_combine_full_texture;
212 extern cvar_t r_q1bsp_lightmap_updates_hidden_surfaces;
213
214 void R_NewExplosion(const vec3_t org);
215 void R_UpdateVariables(void); // must call after setting up most of r_refdef, but before calling R_RenderView
216 void R_RenderView(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height); // must set r_refdef and call R_UpdateVariables and CL_UpdateEntityShading first
217 void R_RenderView_UpdateViewVectors(void); // just updates r_refdef.view.{forward,left,up,origin,right,inverse_matrix}
218
219 float RSurf_FogPoint(const float *v);
220 float RSurf_FogVertex(const float *v);
221
222 typedef enum r_refdef_scene_type_s {
223         RST_CLIENT,
224         RST_MENU,
225         RST_COUNT
226 } r_refdef_scene_type_t;
227
228 typedef enum r_viewport_type_e
229 {
230         R_VIEWPORTTYPE_ORTHO,
231         R_VIEWPORTTYPE_PERSPECTIVE,
232         R_VIEWPORTTYPE_PERSPECTIVE_INFINITEFARCLIP,
233         R_VIEWPORTTYPE_PERSPECTIVECUBESIDE,
234         R_VIEWPORTTYPE_TOTAL
235 }
236 r_viewport_type_t;
237
238 typedef struct r_viewport_s
239 {
240         matrix4x4_t cameramatrix;  ///< from entity (transforms from camera entity to world)
241         matrix4x4_t viewmatrix;    ///< actual matrix for rendering (transforms to viewspace)
242         matrix4x4_t projectmatrix; ///< actual projection matrix (transforms from viewspace to screen)
243         int x;
244         int y;
245         int z;
246         int width;
247         int height;
248         int depth;
249         r_viewport_type_t type;
250         float screentodepth[2];    ///< used by deferred renderer to calculate linear depth from device depth coordinates
251 }
252 r_viewport_t;
253
254 typedef struct r_refdef_view_s
255 {
256         // view information (changes multiple times per frame)
257         // if any of these variables change then r_refdef.viewcache must be regenerated
258         // by calling R_View_Update
259         // (which also updates viewport, scissor, colormask)
260
261         // it is safe and expected to copy this into a structure on the stack and
262         // call the renderer recursively, then restore from the stack afterward
263         // (as long as R_View_Update is called)
264
265         // eye position information
266         matrix4x4_t matrix, inverse_matrix;
267         vec3_t origin;
268         vec3_t forward;
269         vec3_t left;
270         vec3_t right;
271         vec3_t up;
272         int numfrustumplanes;
273         mplane_t frustum[6];
274         qbool useclipplane;
275         qbool usecustompvs; ///< uses r_refdef.viewcache.pvsbits as-is rather than computing it
276         mplane_t clipplane;
277         float frustum_x, frustum_y;
278         vec3_t frustumcorner[4];
279         /// if turned off it renders an ortho view
280         int useperspective;
281         /// allows visibility culling based on the view origin (e.g. pvs and R_CanSeeBox)
282         /// this is turned off by:
283         /// r_trippy
284         /// !r_refdef.view.useperspective
285         /// (sometimes) r_refdef.view.useclipplane
286         int usevieworiginculling;
287         float ortho_x, ortho_y;
288
289         // screen area to render in
290         int x;
291         int y;
292         int z;
293         int width;
294         int height;
295         int depth;
296         r_viewport_t viewport; ///< note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and height
297
298         /// which color components to allow (for anaglyph glasses)
299         int colormask[4];
300
301         /// global RGB color multiplier for rendering
302         float colorscale;
303
304         /// whether to call R_ClearScreen before rendering stuff
305         qbool clear;
306         /// if true, don't clear or do any post process effects (bloom, etc)
307         qbool isoverlay;
308         /// if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e.g. by r_speeds 1, showtex, prydon cursor)
309         qbool ismain;
310
311         // whether to draw r_showtris and such, this is only true for the main
312         // view render, all secondary renders (mirrors, portals, cameras,
313         // distortion effects, etc) omit such debugging information
314         qbool showdebug;
315
316         // these define which values to use in GL_CullFace calls to request frontface or backface culling
317         int cullface_front;
318         int cullface_back;
319
320         /// render quality (0 to 1) - affects r_drawparticles_drawdistance and others
321         float quality;
322 }
323 r_refdef_view_t;
324
325 typedef struct r_refdef_viewcache_s
326 {
327         // updated by gl_main_newmap()
328         int maxentities;
329         int world_numclusters;
330         int world_numclusterbytes;
331         int world_numleafs;
332         int world_numsurfaces;
333
334         // these properties are generated by R_View_Update()
335
336         /// which entities are currently visible for this viewpoint
337         /// (the used range is 0...r_refdef.scene.numentities)
338         unsigned char *entityvisible;
339
340         // flag arrays used for visibility checking on world model
341         // (all other entities have no per-surface/per-leaf visibility checks)
342         unsigned char *world_pvsbits;
343         unsigned char *world_leafvisible;
344         unsigned char *world_surfacevisible;
345         /// if true, the view is currently in a leaf without pvs data
346         qbool world_novis;
347 }
348 r_refdef_viewcache_t;
349
350 // TODO: really think about which fields should go into scene and which one should stay in refdef [1/7/2008 Black]
351 // maybe also refactor some of the functions to support different setting sources (ie. fogenabled, etc.) for different scenes
352 typedef struct r_refdef_scene_s {
353         /// whether to call S_ExtraUpdate during render to reduce sound chop
354         qbool extraupdate;
355
356         /// (client gameworld) time for rendering time based effects
357         double time;
358
359         /// the world
360         entity_render_t *worldentity;
361
362         /// same as worldentity->model
363         model_t *worldmodel;
364
365         /// renderable entities (excluding world)
366         entity_render_t **entities;
367         int numentities;
368         int maxentities;
369
370         /// field of temporary entities that is reset each (client) frame
371         entity_render_t *tempentities;
372         int numtempentities;
373         int maxtempentities;
374         qbool expandtempentities;
375
376         // renderable dynamic lights
377         rtlight_t *lights[MAX_DLIGHTS];
378         rtlight_t templights[MAX_DLIGHTS];
379         int numlights;
380
381         // intensities for light styles right now, controls rtlights
382         float rtlightstylevalue[MAX_LIGHTSTYLES]; ///< float fraction of base light value
383         // 8.8bit fixed point intensities for light styles
384         // controls intensity lightmap layers
385         unsigned short lightstylevalue[MAX_LIGHTSTYLES]; ///< 8.8 fraction of base light value
386
387         // adds brightness to the whole scene, separate from lightmapintensity
388         // see CL_UpdateEntityShading
389         float ambientintensity;
390         // brightness of lightmap and modellight lighting on materials
391         // see CL_UpdateEntityShading
392         float lightmapintensity;
393
394         qbool rtworld;
395         qbool rtworldshadows;
396         qbool rtdlight;
397         qbool rtdlightshadows;
398 } r_refdef_scene_t;
399
400 typedef struct r_refdef_s
401 {
402         // these fields define the basic rendering information for the world
403         // but not the view, which could change multiple times in one rendered
404         // frame (for example when rendering textures for certain effects)
405
406         // these are set for water warping before
407         // frustum_x/frustum_y are calculated
408         float frustumscale_x, frustumscale_y;
409
410         // current view settings (these get reset a few times during rendering because of water rendering, reflections, etc)
411         r_refdef_view_t view;
412         r_refdef_viewcache_t viewcache;
413
414         // minimum visible distance (pixels closer than this disappear)
415         double nearclip;
416         // maximum visible distance (pixels further than this disappear in 16bpp modes,
417         // in 32bpp an infinite-farclip matrix is used instead)
418         double farclip;
419
420         // fullscreen color blend
421         float viewblend[4];
422
423         r_refdef_scene_t scene;
424
425         float fogplane[4];
426         float fogplaneviewdist;
427         qbool fogplaneviewabove;
428         float fogheightfade;
429         float fogcolor[3];
430         float fogrange;
431         float fograngerecip;
432         float fogmasktabledistmultiplier;
433 #define FOGMASKTABLEWIDTH 1024
434         float fogmasktable[FOGMASKTABLEWIDTH];
435         float fogmasktable_start, fogmasktable_alpha, fogmasktable_range, fogmasktable_density;
436         float fog_density;
437         float fog_red;
438         float fog_green;
439         float fog_blue;
440         float fog_alpha;
441         float fog_start;
442         float fog_end;
443         float fog_height;
444         float fog_fadedepth;
445         qbool fogenabled;
446         qbool oldgl_fogenable;
447
448         // new flexible texture height fog (overrides normal fog)
449         char fog_height_texturename[64]; // note: must be 64 for the sscanf code
450         unsigned char *fog_height_table1d;
451         unsigned char *fog_height_table2d;
452         int fog_height_tablesize; // enable
453         float fog_height_tablescale;
454         float fog_height_texcoordscale;
455         char fogheighttexturename[64]; // detects changes to active fog height texture
456
457         int draw2dstage; // 0 = no, 1 = yes, other value = needs setting up again
458
459         // true during envmap command capture
460         qbool envmap;
461
462         // whether to draw world lights realtime, dlights realtime, and their shadows
463         float polygonfactor;
464         float polygonoffset;
465
466         // how long R_RenderView took on the previous frame
467         double lastdrawscreentime;
468
469         // rendering stats for r_speeds display
470         // (these are incremented in many places)
471         int stats[r_stat_count];
472 }
473 r_refdef_t;
474
475 extern r_refdef_t r_refdef;
476
477 void R_SelectScene( r_refdef_scene_type_t scenetype );
478 r_refdef_scene_t * R_GetScenePointer( r_refdef_scene_type_t scenetype );
479
480 void R_SkinFrame_PrepareForPurge(void);
481 void R_SkinFrame_MarkUsed(skinframe_t *skinframe);
482 void R_SkinFrame_PurgeSkinFrame(skinframe_t *skinframe);
483 void R_SkinFrame_Purge(void);
484 // set last to NULL to start from the beginning
485 skinframe_t *R_SkinFrame_FindNextByName( skinframe_t *last, const char *name );
486 skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qbool add);
487 skinframe_t *R_SkinFrame_LoadExternal(const char *name, int textureflags, qbool complain, qbool fallbacknotexture);
488 skinframe_t *R_SkinFrame_LoadExternal_SkinFrame(skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture);
489 skinframe_t *R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB);
490 skinframe_t *R_SkinFrame_LoadInternalQuake(const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height);
491 skinframe_t *R_SkinFrame_LoadInternal8bit(const char *name, int textureflags, const unsigned char *skindata, int width, int height, const unsigned int *palette, const unsigned int *alphapalette);
492 skinframe_t *R_SkinFrame_LoadMissing(void);
493 skinframe_t *R_SkinFrame_LoadNoTexture(void);
494 skinframe_t *R_SkinFrame_LoadInternalUsingTexture(const char *name, int textureflags, rtexture_t *tex, int width, int height, qbool sRGB);
495
496 rtexture_t *R_GetCubemap(const char *basename);
497
498 void R_View_WorldVisibility(qbool forcenovis);
499 void R_DrawParticles(void);
500 void R_DrawExplosions(void);
501
502 #define gl_solid_format 3
503 #define gl_alpha_format 4
504
505 qbool R_CullFrustum(const vec3_t mins, const vec3_t maxs);
506 qbool R_CullBox(const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes);
507 qbool R_CanSeeBox(int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs);
508
509 #include "r_modules.h"
510
511 #include "meshqueue.h"
512
513 /// free all R_FrameData memory
514 void R_FrameData_Reset(void);
515 /// prepare for a new frame, recycles old buffers if a resize occurred previously
516 void R_FrameData_NewFrame(void);
517 /// allocate some temporary memory for your purposes
518 void *R_FrameData_Alloc(size_t size);
519 /// allocate some temporary memory and copy this data into it
520 void *R_FrameData_Store(size_t size, void *data);
521 /// set a marker that allows you to discard the following temporary memory allocations
522 void R_FrameData_SetMark(void);
523 /// discard recent memory allocations (rewind to marker)
524 void R_FrameData_ReturnToMark(void);
525
526 /// enum of the various types of hardware buffer object used in rendering
527 /// note that the r_buffermegs[] array must be maintained to match this
528 typedef enum r_bufferdata_type_e
529 {
530         R_BUFFERDATA_VERTEX, /// vertex buffer
531         R_BUFFERDATA_INDEX16, /// index buffer - 16bit (because D3D cares)
532         R_BUFFERDATA_INDEX32, /// index buffer - 32bit (because D3D cares)
533         R_BUFFERDATA_UNIFORM, /// uniform buffer
534         R_BUFFERDATA_COUNT /// how many kinds of buffer we have
535 }
536 r_bufferdata_type_t;
537
538 /// free all dynamic vertex/index/uniform buffers
539 void R_BufferData_Reset(void);
540 /// begin a new frame (recycle old buffers)
541 void R_BufferData_NewFrame(void);
542 /// request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and offset, always successful
543 r_meshbuffer_t *R_BufferData_Store(size_t size, const void *data, r_bufferdata_type_t type, int *returnbufferoffset);
544
545 /// free all R_AnimCache memory
546 void R_AnimCache_Free(void);
547 /// clear the animcache pointers on all known render entities
548 void R_AnimCache_ClearCache(void);
549 /// get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangents)
550 qbool R_AnimCache_GetEntity(entity_render_t *ent, qbool wantnormals, qbool wanttangents);
551 /// generate animcache data for all entities marked visible
552 void R_AnimCache_CacheVisibleEntities(void);
553
554 extern cvar_t r_render;
555 extern cvar_t r_renderview;
556 extern cvar_t r_waterwarp;
557
558 extern cvar_t r_glsl_offsetmapping;
559 extern cvar_t r_glsl_offsetmapping_reliefmapping;
560 extern cvar_t r_glsl_offsetmapping_scale;
561 extern cvar_t r_glsl_offsetmapping_lod;
562 extern cvar_t r_glsl_offsetmapping_lod_distance;
563 extern cvar_t r_glsl_deluxemapping;
564
565 extern cvar_t gl_polyblend;
566
567 extern cvar_t cl_deathfade;
568
569 extern cvar_t r_smoothnormals_areaweighting;
570
571 extern cvar_t r_test;
572
573 #include "gl_backend.h"
574
575 extern rtexture_t *r_texture_blanknormalmap;
576 extern rtexture_t *r_texture_white;
577 extern rtexture_t *r_texture_grey128;
578 extern rtexture_t *r_texture_black;
579 extern rtexture_t *r_texture_notexture;
580 extern rtexture_t *r_texture_whitecube;
581 extern rtexture_t *r_texture_normalizationcube;
582 extern rtexture_t *r_texture_fogattenuation;
583 extern rtexture_t *r_texture_fogheighttexture;
584
585 extern unsigned int r_queries[MAX_OCCLUSION_QUERIES];
586 extern unsigned int r_numqueries;
587 extern unsigned int r_maxqueries;
588
589 void R_TimeReport(const char *name);
590
591 // r_stain
592 void R_Stain(const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2);
593
594 void R_CalcBeam_Vertex3f(float *vert, const float *org1, const float *org2, float width);
595 void R_CalcSprite_Vertex3f(float *vertex3f, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2);
596
597 extern mempool_t *r_main_mempool;
598
599 typedef struct rsurfacestate_s
600 {
601         // current model array pointers
602         // these may point to processing buffers if model is animated,
603         // otherwise they point to static data.
604         // these are not directly used for rendering, they are just another level
605         // of processing
606         //
607         // these either point at array_model* buffers (if the model is animated)
608         // or the model->surfmesh.data_* buffers (if the model is not animated)
609         //
610         // these are only set when an entity render begins, they do not change on
611         // a per surface basis.
612         //
613         // this indicates the model* arrays are pointed at array_model* buffers
614         // (in other words, the model has been animated in software)
615         qbool                    forcecurrenttextureupdate; // set for RSurf_ActiveCustomEntity to force R_GetCurrentTexture to recalculate the texture parameters (such as entity alpha)
616         qbool                    modelgeneratedvertex;
617         // skeletal animation can be done by entity (animcache) or per batch,
618         // batch may be non-skeletal even if entity is skeletal, indicating that
619         // the dynamicvertex code path had to apply skeletal manually for a case
620         // where gpu-skinning is not possible, for this reason batch has its own
621         // variables
622         int                         entityskeletalnumtransforms; // how many transforms are used for this mesh
623         float                      *entityskeletaltransform3x4; // use gpu-skinning shader on this mesh
624         const r_meshbuffer_t       *entityskeletaltransform3x4buffer; // uniform buffer
625         int                         entityskeletaltransform3x4offset;
626         int                         entityskeletaltransform3x4size;
627         float                      *modelvertex3f;
628         const r_meshbuffer_t       *modelvertex3f_vertexbuffer;
629         int                         modelvertex3f_bufferoffset;
630         float                      *modelsvector3f;
631         const r_meshbuffer_t       *modelsvector3f_vertexbuffer;
632         int                         modelsvector3f_bufferoffset;
633         float                      *modeltvector3f;
634         const r_meshbuffer_t       *modeltvector3f_vertexbuffer;
635         int                         modeltvector3f_bufferoffset;
636         float                      *modelnormal3f;
637         const r_meshbuffer_t       *modelnormal3f_vertexbuffer;
638         int                         modelnormal3f_bufferoffset;
639         float                      *modellightmapcolor4f;
640         const r_meshbuffer_t       *modellightmapcolor4f_vertexbuffer;
641         int                         modellightmapcolor4f_bufferoffset;
642         float                      *modeltexcoordtexture2f;
643         const r_meshbuffer_t       *modeltexcoordtexture2f_vertexbuffer;
644         int                         modeltexcoordtexture2f_bufferoffset;
645         float                      *modeltexcoordlightmap2f;
646         const r_meshbuffer_t       *modeltexcoordlightmap2f_vertexbuffer;
647         int                         modeltexcoordlightmap2f_bufferoffset;
648         unsigned char              *modelskeletalindex4ub;
649         const r_meshbuffer_t       *modelskeletalindex4ub_vertexbuffer;
650         int                         modelskeletalindex4ub_bufferoffset;
651         unsigned char              *modelskeletalweight4ub;
652         const r_meshbuffer_t       *modelskeletalweight4ub_vertexbuffer;
653         int                         modelskeletalweight4ub_bufferoffset;
654         int                        *modelelement3i;
655         const r_meshbuffer_t       *modelelement3i_indexbuffer;
656         int                         modelelement3i_bufferoffset;
657         unsigned short             *modelelement3s;
658         const r_meshbuffer_t       *modelelement3s_indexbuffer;
659         int                         modelelement3s_bufferoffset;
660         int                        *modellightmapoffsets;
661         int                         modelnumvertices;
662         int                         modelnumtriangles;
663         const msurface_t           *modelsurfaces;
664         // current rendering array pointers
665         // these may point to any of several different buffers depending on how
666         // much processing was needed to prepare this model for rendering
667         // these usually equal the model* pointers, they only differ if
668         // deformvertexes is used in a q3 shader, and consequently these can
669         // change on a per-surface basis (according to rsurface.texture)
670         qbool                    batchgeneratedvertex;
671         qbool                    batchmultidraw;
672         int                         batchmultidrawnumsurfaces;
673         const msurface_t          **batchmultidrawsurfacelist;
674         int                         batchfirstvertex;
675         int                         batchnumvertices;
676         int                         batchfirsttriangle;
677         int                         batchnumtriangles;
678         float                      *batchvertex3f;
679         const r_meshbuffer_t       *batchvertex3f_vertexbuffer;
680         int                         batchvertex3f_bufferoffset;
681         float                      *batchsvector3f;
682         const r_meshbuffer_t       *batchsvector3f_vertexbuffer;
683         int                         batchsvector3f_bufferoffset;
684         float                      *batchtvector3f;
685         const r_meshbuffer_t       *batchtvector3f_vertexbuffer;
686         int                         batchtvector3f_bufferoffset;
687         float                      *batchnormal3f;
688         const r_meshbuffer_t       *batchnormal3f_vertexbuffer;
689         int                         batchnormal3f_bufferoffset;
690         float                      *batchlightmapcolor4f;
691         const r_meshbuffer_t       *batchlightmapcolor4f_vertexbuffer;
692         int                         batchlightmapcolor4f_bufferoffset;
693         float                      *batchtexcoordtexture2f;
694         const r_meshbuffer_t       *batchtexcoordtexture2f_vertexbuffer;
695         int                         batchtexcoordtexture2f_bufferoffset;
696         float                      *batchtexcoordlightmap2f;
697         const r_meshbuffer_t       *batchtexcoordlightmap2f_vertexbuffer;
698         int                         batchtexcoordlightmap2f_bufferoffset;
699         unsigned char              *batchskeletalindex4ub;
700         const r_meshbuffer_t       *batchskeletalindex4ub_vertexbuffer;
701         int                         batchskeletalindex4ub_bufferoffset;
702         unsigned char              *batchskeletalweight4ub;
703         const r_meshbuffer_t       *batchskeletalweight4ub_vertexbuffer;
704         int                         batchskeletalweight4ub_bufferoffset;
705         int                        *batchelement3i;
706         const r_meshbuffer_t       *batchelement3i_indexbuffer;
707         int                         batchelement3i_bufferoffset;
708         unsigned short             *batchelement3s;
709         const r_meshbuffer_t       *batchelement3s_indexbuffer;
710         int                         batchelement3s_bufferoffset;
711         int                         batchskeletalnumtransforms;
712         float                      *batchskeletaltransform3x4;
713         const r_meshbuffer_t       *batchskeletaltransform3x4buffer; // uniform buffer
714         int                         batchskeletaltransform3x4offset;
715         int                         batchskeletaltransform3x4size;
716
717         // some important fields from the entity
718         int ent_skinnum;
719         int ent_qwskin;
720         int ent_flags;
721         int ent_alttextures; // used by q1bsp animated textures (pressed buttons)
722         double shadertime; // r_refdef.scene.time - ent->shadertime
723         // transform matrices to render this entity and effects on this entity
724         matrix4x4_t matrix;
725         matrix4x4_t inversematrix;
726         // scale factors for transforming lengths into/out of entity space
727         float matrixscale;
728         float inversematrixscale;
729         // animation blending state from entity
730         frameblend_t frameblend[MAX_FRAMEBLENDS];
731         skeleton_t *skeleton;
732         // view location in model space
733         vec3_t localvieworigin;
734         // polygon offset data for submodels
735         float basepolygonfactor;
736         float basepolygonoffset;
737         // current textures in batching code
738         texture_t *texture;
739         rtexture_t *lightmaptexture;
740         rtexture_t *deluxemaptexture;
741         // whether lightmapping is active on this batch
742         // (otherwise vertex colored)
743         qbool uselightmaptexture;
744         // fog plane in model space for direct application to vertices
745         float fograngerecip;
746         float fogmasktabledistmultiplier;
747         float fogplane[4];
748         float fogheightfade;
749         float fogplaneviewdist;
750
751         // rtlight rendering
752         // light currently being rendered
753         const rtlight_t *rtlight;
754
755         // this is the location of the light in entity space
756         vec3_t entitylightorigin;
757         // this transforms entity coordinates to light filter cubemap coordinates
758         // (also often used for other purposes)
759         matrix4x4_t entitytolight;
760         // based on entitytolight this transforms -1 to +1 to 0 to 1 for purposes
761         // of attenuation texturing in full 3D (Z result often ignored)
762         matrix4x4_t entitytoattenuationxyz;
763         // this transforms only the Z to S, and T is always 0.5
764         matrix4x4_t entitytoattenuationz;
765
766         // user wavefunc parameters (from csqc)
767         float userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
768
769         // pointer to an entity_render_t used only by R_GetCurrentTexture and
770         // RSurf_ActiveModelEntity as a unique id within each frame (see r_frame
771         // also)
772         entity_render_t *entity;
773 }
774 rsurfacestate_t;
775
776 extern rsurfacestate_t rsurface;
777
778 void R_HDR_UpdateIrisAdaptation(const vec3_t point);
779
780 void RSurf_ActiveModelEntity(const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass);
781 void RSurf_ActiveCustomEntity(const matrix4x4_t *matrix, const matrix4x4_t *inversematrix, int entflags, double shadertime, float r, float g, float b, float a, int numvertices, const float *vertex3f, const float *texcoord2f, const float *normal3f, const float *svector3f, const float *tvector3f, const float *color4f, int numtriangles, const int *element3i, const unsigned short *element3s, qbool wantnormals, qbool wanttangents);
782 void RSurf_SetupDepthAndCulling(bool ui);
783
784 extern int r_textureframe; ///< used only by R_GetCurrentTexture, incremented per view and per UI render
785 texture_t *R_GetCurrentTexture(texture_t *t);
786 void R_DrawModelSurfaces(entity_render_t *ent, qbool skysurfaces, qbool writedepth, qbool depthonly, qbool debug, qbool prepass, qbool ui);
787 void R_DrawCustomSurface(skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui);
788 void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui);
789
790 #define BATCHNEED_ARRAY_VERTEX                (1<< 0) // set up rsurface.batchvertex3f
791 #define BATCHNEED_ARRAY_NORMAL                (1<< 1) // set up rsurface.batchnormal3f
792 #define BATCHNEED_ARRAY_VECTOR                (1<< 2) // set up rsurface.batchsvector3f and rsurface.batchtvector3f
793 #define BATCHNEED_ARRAY_VERTEXTINTCOLOR       (1<< 3) // set up rsurface.batchvertexcolor4f
794 #define BATCHNEED_ARRAY_VERTEXCOLOR           (1<< 4) // set up rsurface.batchlightmapcolor4f
795 #define BATCHNEED_ARRAY_TEXCOORD              (1<< 5) // set up rsurface.batchtexcoordtexture2f
796 #define BATCHNEED_ARRAY_LIGHTMAP              (1<< 6) // set up rsurface.batchtexcoordlightmap2f
797 #define BATCHNEED_ARRAY_SKELETAL              (1<< 7) // set up skeletal index and weight data for vertex shader
798 #define BATCHNEED_NOGAPS                      (1<< 8) // force vertex copying if firstvertex is not zero or there are gaps
799 #define BATCHNEED_ALWAYSCOPY                  (1<< 9) // force vertex copying unconditionally - useful if you want to modify colors
800 #define BATCHNEED_ALLOWMULTIDRAW              (1<<10) // allow multiple draws
801 void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist);
802 void RSurf_UploadBuffersForBatch(void);
803 void RSurf_DrawBatch(void);
804
805 void R_DecalSystem_SplatEntities(const vec3_t org, const vec3_t normal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float size);
806
807 typedef enum rsurfacepass_e
808 {
809         RSURFPASS_BASE,
810         RSURFPASS_BACKGROUND,
811         RSURFPASS_RTLIGHT,
812         RSURFPASS_DEFERREDGEOMETRY
813 }
814 rsurfacepass_t;
815
816 void R_SetupShader_Generic(rtexture_t *t, qbool usegamma, qbool notrippy, qbool suppresstexalpha);
817 void R_SetupShader_Generic_NoTexture(qbool usegamma, qbool notrippy);
818 void R_SetupShader_DepthOrShadow(qbool notrippy, qbool depthrgb, qbool skeletal);
819 void R_SetupShader_Surface(const float ambientcolor[3], const float diffusecolor[3], const float specularcolor[3], rsurfacepass_t rsurfacepass, int texturenumsurfaces, const msurface_t **texturesurfacelist, void *waterplane, qbool notrippy, qbool ui);
820 void R_SetupShader_DeferredLight(const rtlight_t *rtlight);
821
822 typedef struct r_rendertarget_s {
823         // texcoords for sampling from the viewport (clockwise: 0,0 1,0 1,1 0,1)
824         float texcoord2f[8];
825         // textures are this size and type
826         int texturewidth;
827         int textureheight;
828         // TEXTYPE for each color target - usually TEXTYPE_COLORBUFFER16F
829         textype_t colortextype[4];
830         // TEXTYPE for depth target - usually TEXTYPE_DEPTHBUFFER24 or TEXTYPE_SHADOWMAP24_COMP
831         textype_t depthtextype;
832         // if true the depth target will be a renderbuffer rather than a texture (still rtexture_t though)
833         qbool depthisrenderbuffer;
834         // framebuffer object referencing the textures
835         int fbo;
836         // there can be up to 4 color targets and 1 depth target, the depthtexture
837         // may be a real texture (readable) or just a renderbuffer (not readable,
838         // but potentially faster)
839         rtexture_t *colortexture[4];
840         rtexture_t *depthtexture;
841         // a rendertarget will not be reused in the same frame (host.realtime == lastusetime),
842         // on a new frame, matching rendertargets will be reused (texturewidth, textureheight, number of color and depth textures and their types),
843         // when a new frame arrives the rendertargets can be reused by requests for matching texturewidth,textureheight and fbo configuration (the number of color and depth textures), when a rendertarget is not reused for > 200ms (host.realtime - lastusetime > 0.2) the rendertarget's resources will be freed (fbo, textures) and it can be reused for any target in future frames
844         double lastusetime;
845 } r_rendertarget_t;
846
847 // called each frame after render to delete render targets that have not been used for a while
848 void R_RenderTarget_FreeUnused(qbool force);
849 // returns a rendertarget, creates rendertarget if needed or intelligently reuses targets across frames if they match and have not been used already this frame
850 r_rendertarget_t *R_RenderTarget_Get(int texturewidth, int textureheight, textype_t depthtextype, qbool depthisrenderbuffer, textype_t colortextype0, textype_t colortextype1, textype_t colortextype2, textype_t colortextype3);
851
852 typedef struct r_waterstate_waterplane_s
853 {
854         r_rendertarget_t *rt_refraction; // MATERIALFLAG_WATERSHADER or MATERIALFLAG_REFRACTION
855         r_rendertarget_t *rt_reflection; // MATERIALFLAG_WATERSHADER or MATERIALFLAG_REFLECTION
856         r_rendertarget_t *rt_camera; // MATERIALFLAG_CAMERA
857         mplane_t plane;
858         int materialflags; // combined flags of all water surfaces on this plane
859         unsigned char pvsbits[(MAX_MAP_LEAFS+7)>>3]; // FIXME: buffer overflow on huge maps
860         qbool pvsvalid;
861         int camera_entity;
862         vec3_t mins, maxs;
863 }
864 r_waterstate_waterplane_t;
865
866 typedef struct r_waterstate_s
867 {
868         int waterwidth, waterheight;
869         int texturewidth, textureheight;
870         int camerawidth, cameraheight;
871
872         int maxwaterplanes; // same as MAX_WATERPLANES
873         int numwaterplanes;
874         r_waterstate_waterplane_t waterplanes[MAX_WATERPLANES];
875
876         float screenscale[2];
877         float screencenter[2];
878
879         qbool enabled;
880
881         qbool renderingscene; // true while rendering a refraction or reflection texture, disables water surfaces
882         qbool hideplayer;
883 }
884 r_waterstate_t;
885
886 typedef struct r_framebufferstate_s
887 {
888         textype_t textype; // type of color buffer we're using (dependent on r_viewfbo cvar)
889         int screentexturewidth, screentextureheight; // dimensions of texture
890
891         // rt_* fields are per-RenderView so we reset them in R_Bloom_StartFrame
892         r_rendertarget_t *rt_screen;
893         r_rendertarget_t *rt_bloom;
894
895         rtexture_t *ghosttexture; // for r_motionblur (not recommended on multi-GPU hardware!)
896         float ghosttexcoord2f[8]; // for r_motionblur
897
898         int bloomwidth, bloomheight;
899
900         // arrays for rendering the screen passes
901         float offsettexcoord2f[8]; // temporary use while updating bloomtexture[]
902
903         r_waterstate_t water;
904
905         qbool ghosttexture_valid; // don't draw garbage on first frame with motionblur
906         qbool usedepthtextures; // use depth texture instead of depth renderbuffer (faster if you need to read it later anyway)
907
908         // rendertargets (fbo and viewport), these can be reused across frames
909         memexpandablearray_t rendertargets;
910 }
911 r_framebufferstate_t;
912
913 extern r_framebufferstate_t r_fb;
914
915 extern cvar_t r_viewfbo;
916
917 void R_ResetViewRendering2D_Common(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2); // this is called by R_ResetViewRendering2D and _DrawQ_Setup and internal
918 void R_ResetViewRendering2D(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight);
919 void R_ResetViewRendering3D(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight);
920 void R_SetupView(qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight);
921 void R_DebugLine(vec3_t start, vec3_t end);
922 extern const float r_screenvertex3f[12];
923 extern cvar_t r_showspriteedges;
924 extern cvar_t r_showparticleedges;
925 extern cvar_t r_shadows;
926 extern cvar_t r_shadows_darken;
927 extern cvar_t r_shadows_drawafterrtlighting;
928 extern cvar_t r_shadows_castfrombmodels;
929 extern cvar_t r_shadows_throwdistance;
930 extern cvar_t r_shadows_throwdirection;
931 extern cvar_t r_shadows_focus;
932 extern cvar_t r_shadows_shadowmapscale;
933 extern cvar_t r_shadows_shadowmapbias;
934 extern cvar_t r_transparent_alphatocoverage;
935 extern cvar_t r_transparent_sortsurfacesbynearest;
936 extern cvar_t r_transparent_useplanardistance;
937 extern cvar_t r_transparent_sortarraysize;
938 extern cvar_t r_transparent_sortmindist;
939 extern cvar_t r_transparent_sortmaxdist;
940
941 extern qbool r_shadow_usingdeferredprepass;
942 extern rtexture_t *r_shadow_attenuationgradienttexture;
943 extern rtexture_t *r_shadow_attenuation2dtexture;
944 extern rtexture_t *r_shadow_attenuation3dtexture;
945 extern qbool r_shadow_usingshadowmap2d;
946 extern qbool r_shadow_usingshadowmaportho;
947 extern float r_shadow_modelshadowmap_texturescale[4];
948 extern float r_shadow_modelshadowmap_parameters[4];
949 extern float r_shadow_lightshadowmap_texturescale[4];
950 extern float r_shadow_lightshadowmap_parameters[4];
951 extern qbool r_shadow_shadowmapvsdct;
952 extern rtexture_t *r_shadow_shadowmap2ddepthbuffer;
953 extern rtexture_t *r_shadow_shadowmap2ddepthtexture;
954 extern rtexture_t *r_shadow_shadowmapvsdcttexture;
955 extern matrix4x4_t r_shadow_shadowmapmatrix;
956 extern int r_shadow_prepass_width;
957 extern int r_shadow_prepass_height;
958 extern rtexture_t *r_shadow_prepassgeometrydepthbuffer;
959 extern rtexture_t *r_shadow_prepassgeometrynormalmaptexture;
960 extern rtexture_t *r_shadow_prepasslightingdiffusetexture;
961 extern rtexture_t *r_shadow_prepasslightingspeculartexture;
962 extern int r_shadow_viewfbo;
963 extern rtexture_t *r_shadow_viewdepthtexture;
964 extern rtexture_t *r_shadow_viewcolortexture;
965 extern int r_shadow_viewx;
966 extern int r_shadow_viewy;
967 extern int r_shadow_viewwidth;
968 extern int r_shadow_viewheight;
969
970 void R_RenderScene(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight);
971 void R_RenderWaterPlanes(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight);
972
973 void R_Model_Sprite_Draw(entity_render_t *ent);
974
975 struct prvm_prog_s;
976 void R_UpdateFog(void);
977 qbool CL_VM_UpdateView(double frametime);
978 void CL_VM_DrawHud(double frametime);
979 void SCR_DrawConsole(void);
980 void R_Shadow_EditLights_DrawSelectedLightProperties(void);
981 void R_DecalSystem_Reset(decalsystem_t *decalsystem);
982 void R_Shadow_UpdateBounceGridTexture(void);
983 void R_DrawPortals(void);
984 void R_BuildLightMap(const entity_render_t *ent, msurface_t *surface, int combine);
985 void R_Water_AddWaterPlane(msurface_t *surface, int entno);
986 int R_Shadow_GetRTLightInfo(unsigned int lightindex, float *origin, float *radius, float *color);
987 dp_font_t *FindFont(const char *title, qbool allocate_new);
988 void LoadFont(qbool override, const char *name, dp_font_t *fnt, float scale, float voffset);
989
990 void Render_Init(void);
991
992 // these are called by Render_Init
993 void R_Textures_Init(void);
994 void GL_Draw_Init(void);
995 void GL_Main_Init(void);
996 void R_Shadow_Init(void);
997 void R_Sky_Init(void);
998 void GL_Surf_Init(void);
999 void R_Particles_Init(void);
1000 void R_Explosion_Init(void);
1001 void gl_backend_init(void);
1002 void Sbar_Init(void);
1003 void R_LightningBeams_Init(void);
1004 void Mod_RenderInit(void);
1005 void Font_Init(void);
1006
1007 qbool R_CompileShader_CheckStaticParms(void);
1008 void R_GLSL_Restart_f(cmd_state_t *cmd);
1009
1010 #endif