]> icculus.org git repositories - divverent/darkplaces.git/blob - render.h
patch from esteel that fixes the +/-button command descriptions (they all said button3)
[divverent/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 // flag arrays used for visibility checking on world model
25 // (all other entities have no per-surface/per-leaf visibility checks)
26 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
27 extern unsigned char r_pvsbits[(32768+7)>>3];
28 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
29 extern unsigned char r_worldleafvisible[32768];
30 // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
31 extern unsigned char r_worldsurfacevisible[262144];
32
33 extern matrix4x4_t r_identitymatrix;
34
35 // 1.0f / N table
36 extern float ixtable[4096];
37
38 // far clip distance for scene
39 extern float r_farclip;
40
41 // fog stuff
42 extern void FOG_clear(void);
43 extern float fog_density, fog_red, fog_green, fog_blue;
44
45 // sky stuff
46 extern cvar_t r_sky;
47 extern cvar_t r_skyscroll1;
48 extern cvar_t r_skyscroll2;
49 extern int skyrendernow, skyrendermasked;
50 extern int R_SetSkyBox(const char *sky);
51 extern void R_SkyStartFrame(void);
52 extern void R_Sky(void);
53 extern void R_ResetSkyBox(void);
54
55 // SHOWLMP stuff (Nehahra)
56 extern void SHOWLMP_decodehide(void);
57 extern void SHOWLMP_decodeshow(void);
58 extern void SHOWLMP_drawall(void);
59 extern void SHOWLMP_clear(void);
60
61 // render profiling stuff
62 extern char r_speeds_string[1024];
63
64 // lighting stuff
65 extern cvar_t r_ambient;
66 extern cvar_t gl_flashblend;
67
68 // vis stuff
69 extern cvar_t r_novis;
70
71 extern cvar_t r_lerpsprites;
72 extern cvar_t r_lerpmodels;
73 extern cvar_t r_waterscroll;
74
75 extern cvar_t developer_texturelogging;
76
77 typedef struct rmesh_s
78 {
79         // vertices of this mesh
80         int maxvertices;
81         int numvertices;
82         float *vertex3f;
83         float *svector3f;
84         float *tvector3f;
85         float *normal3f;
86         float *texcoord2f;
87         float *texcoordlightmap2f;
88         float *color4f;
89         // triangles of this mesh
90         int maxtriangles;
91         int numtriangles;
92         int *element3i;
93         int *neighbor3i;
94         // snapping epsilon
95         float epsilon2;
96 }
97 rmesh_t;
98
99 // useful functions for rendering
100 void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b);
101 void R_FillColors(float *out, int verts, float r, float g, float b, float a);
102 int R_Mesh_AddVertex3f(rmesh_t *mesh, const float *v);
103 void R_Mesh_AddPolygon3f(rmesh_t *mesh, int numvertices, float *vertex3f);
104 void R_Mesh_AddBrushMeshFromPlanes(rmesh_t *mesh, int numplanes, mplane_t *planes);
105
106 #define TOP_RANGE               16                      // soldier uniform colors
107 #define BOTTOM_RANGE    96
108
109 //=============================================================================
110
111 extern int r_framecount;
112 extern mplane_t frustum[5];
113
114 typedef struct renderstats_s
115 {
116         int entities;
117         int entities_surfaces;
118         int entities_triangles;
119         int world_leafs;
120         int world_portals;
121         int particles;
122         int meshes;
123         int meshes_elements;
124         int lights;
125         int lights_clears;
126         int lights_scissored;
127         int lights_lighttriangles;
128         int lights_shadowtriangles;
129         int lights_dynamicshadowtriangles;
130         int bloom;
131         int bloom_copypixels;
132         int bloom_drawpixels;
133 }
134 renderstats_t;
135
136 extern renderstats_t renderstats;
137
138 // brightness of world lightmaps and related lighting
139 // (often reduced when world rtlights are enabled)
140 extern float r_lightmapintensity;
141 // whether to draw world lights realtime, dlights realtime, and their shadows
142 extern qboolean r_rtworld;
143 extern qboolean r_rtworldshadows;
144 extern qboolean r_rtdlight;
145 extern qboolean r_rtdlightshadows;
146
147 // forces all rendering to draw triangle outlines
148 extern cvar_t r_showtris;
149 extern cvar_t r_showtris_polygonoffset;
150 extern cvar_t r_shownormals;
151 extern cvar_t r_showlighting;
152 extern cvar_t r_showshadowvolumes;
153 extern cvar_t r_showcollisionbrushes;
154 extern cvar_t r_showcollisionbrushes_polygonfactor;
155 extern cvar_t r_showcollisionbrushes_polygonoffset;
156 extern cvar_t r_showdisabledepthtest;
157 extern int r_showtrispass;
158
159 //
160 // view origin
161 //
162 extern vec3_t r_vieworigin;
163 extern vec3_t r_viewforward;
164 extern vec3_t r_viewleft;
165 extern vec3_t r_viewright;
166 extern vec3_t r_viewup;
167 extern int r_view_x;
168 extern int r_view_y;
169 extern int r_view_z;
170 extern int r_view_width;
171 extern int r_view_height;
172 extern int r_view_depth;
173 extern matrix4x4_t r_view_matrix;
174
175 extern  mleaf_t         *r_viewleaf, *r_oldviewleaf;
176
177 extern  qboolean        envmap;
178
179 extern cvar_t r_drawentities;
180 extern cvar_t r_drawviewmodel;
181 extern cvar_t r_speeds;
182 extern cvar_t r_fullbright;
183 extern cvar_t r_wateralpha;
184 extern cvar_t r_dynamic;
185
186 void R_Init(void);
187 void R_UpdateWorld(void); // needs no r_refdef
188 void R_RenderView(void); // must call R_UpdateWorld and set r_refdef first
189
190
191 void R_InitSky (unsigned char *src, int bytesperpixel); // called at level load
192
193 void R_WorldVisibility();
194 void R_DrawParticles(void);
195 void R_DrawExplosions(void);
196
197 #define gl_solid_format 3
198 #define gl_alpha_format 4
199
200 int R_CullBox(const vec3_t mins, const vec3_t maxs);
201
202 #define FOGTABLEWIDTH 1024
203 extern vec3_t fogcolor;
204 extern vec_t fogdensity;
205 extern vec_t fogrange;
206 extern vec_t fograngerecip;
207 extern int fogtableindex;
208 extern vec_t fogtabledistmultiplier;
209 extern float fogtable[FOGTABLEWIDTH];
210 extern qboolean fogenabled;
211 #define VERTEXFOGTABLE(dist) (fogtableindex = (int)((dist) * fogtabledistmultiplier), fogtable[bound(0, fogtableindex, FOGTABLEWIDTH - 1)])
212
213 #include "r_modules.h"
214
215 #include "meshqueue.h"
216
217 #include "r_lerpanim.h"
218
219 extern cvar_t r_render;
220 extern cvar_t r_waterwarp;
221
222 extern cvar_t r_textureunits;
223 extern cvar_t gl_polyblend;
224 extern cvar_t gl_dither;
225
226 extern cvar_t r_smoothnormals_areaweighting;
227
228 #include "gl_backend.h"
229
230 #include "r_light.h"
231
232 extern rtexture_t *r_texture_blanknormalmap;
233 extern rtexture_t *r_texture_white;
234 extern rtexture_t *r_texture_black;
235 extern rtexture_t *r_texture_notexture;
236 extern rtexture_t *r_texture_whitecube;
237 extern rtexture_t *r_texture_normalizationcube;
238 extern rtexture_t *r_texture_fogattenuation;
239 extern rtexture_t *r_texture_fogintensity;
240
241 void R_TimeReport(char *name);
242 void R_TimeReport_Start(void);
243 void R_TimeReport_End(void);
244
245 // r_stain
246 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);
247
248 void R_DrawWorldCrosshair(void);
249 void R_Draw2DCrosshair(void);
250
251 void R_CalcBeam_Vertex3f(float *vert, const vec3_t org1, const vec3_t org2, float width);
252 void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, int depthdisable, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca);
253
254 struct entity_render_s;
255 struct texture_s;
256 struct msurface_s;
257 void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t);
258 void R_UpdateAllTextureInfo(entity_render_t *ent);
259 void R_QueueTextureSurfaceList(entity_render_t *ent, struct texture_s *texture, int texturenumsurfaces, const struct msurface_s **texturesurfacelist, const vec3_t modelorg);
260 void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces);
261
262 #endif
263