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