]> icculus.org git repositories - divverent/darkplaces.git/blob - render.h
remove an unused variable
[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 // 1.0f / N table
25 extern float ixtable[4096];
26
27 // fog stuff
28 extern void FOG_clear(void);
29
30 // sky stuff
31 extern cvar_t r_sky;
32 extern cvar_t r_skyscroll1;
33 extern cvar_t r_skyscroll2;
34 extern int skyrendernow, skyrendermasked;
35 extern int R_SetSkyBox(const char *sky);
36 extern void R_SkyStartFrame(void);
37 extern void R_Sky(void);
38 extern void R_ResetSkyBox(void);
39
40 // SHOWLMP stuff (Nehahra)
41 extern void SHOWLMP_decodehide(void);
42 extern void SHOWLMP_decodeshow(void);
43 extern void SHOWLMP_drawall(void);
44 extern void SHOWLMP_clear(void);
45
46 // render profiling stuff
47 extern char r_speeds_string[1024];
48 extern int r_timereport_active;
49
50 // lighting stuff
51 extern cvar_t r_ambient;
52 extern cvar_t gl_flashblend;
53
54 // vis stuff
55 extern cvar_t r_novis;
56
57 extern cvar_t r_lerpsprites;
58 extern cvar_t r_lerpmodels;
59 extern cvar_t r_waterscroll;
60
61 extern cvar_t developer_texturelogging;
62
63 typedef struct rmesh_s
64 {
65         // vertices of this mesh
66         int maxvertices;
67         int numvertices;
68         float *vertex3f;
69         float *svector3f;
70         float *tvector3f;
71         float *normal3f;
72         float *texcoord2f;
73         float *texcoordlightmap2f;
74         float *color4f;
75         // triangles of this mesh
76         int maxtriangles;
77         int numtriangles;
78         int *element3i;
79         int *neighbor3i;
80         // snapping epsilon
81         float epsilon2;
82 }
83 rmesh_t;
84
85 // useful functions for rendering
86 void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b);
87 void R_FillColors(float *out, int verts, float r, float g, float b, float a);
88 int R_Mesh_AddVertex3f(rmesh_t *mesh, const float *v);
89 void R_Mesh_AddPolygon3f(rmesh_t *mesh, int numvertices, float *vertex3f);
90 void R_Mesh_AddBrushMeshFromPlanes(rmesh_t *mesh, int numplanes, mplane_t *planes);
91
92 #define TOP_RANGE               16                      // soldier uniform colors
93 #define BOTTOM_RANGE    96
94
95 //=============================================================================
96
97 extern cvar_t r_nearclip;
98
99 // forces all rendering to draw triangle outlines
100 extern cvar_t r_showtris;
101 extern cvar_t r_shownormals;
102 extern cvar_t r_showlighting;
103 extern cvar_t r_showshadowvolumes;
104 extern cvar_t r_showcollisionbrushes;
105 extern cvar_t r_showcollisionbrushes_polygonfactor;
106 extern cvar_t r_showcollisionbrushes_polygonoffset;
107 extern cvar_t r_showdisabledepthtest;
108
109 //
110 // view origin
111 //
112 extern cvar_t r_drawentities;
113 extern cvar_t r_drawviewmodel;
114 extern cvar_t r_speeds;
115 extern cvar_t r_fullbright;
116 extern cvar_t r_wateralpha;
117 extern cvar_t r_dynamic;
118
119 void R_Init(void);
120 void R_UpdateVariables(void); // must call after setting up most of r_refdef, but before calling R_RenderView
121 void R_RenderView(void); // must set r_refdef and call R_UpdateVariables first
122
123
124 void R_InitSky (unsigned char *src, int bytesperpixel); // called at level load
125
126 void R_View_WorldVisibility();
127 void R_DrawParticles(void);
128 void R_DrawExplosions(void);
129
130 #define gl_solid_format 3
131 #define gl_alpha_format 4
132
133 int R_CullBox(const vec3_t mins, const vec3_t maxs);
134
135 #include "r_modules.h"
136
137 #include "meshqueue.h"
138
139 #include "r_lerpanim.h"
140
141 extern cvar_t r_render;
142 extern cvar_t r_waterwarp;
143
144 extern cvar_t r_textureunits;
145 extern cvar_t r_glsl;
146 extern cvar_t r_glsl_offsetmapping;
147 extern cvar_t r_glsl_offsetmapping_reliefmapping;
148 extern cvar_t r_glsl_offsetmapping_scale;
149 extern cvar_t r_glsl_deluxemapping;
150
151 extern cvar_t gl_polyblend;
152 extern cvar_t gl_dither;
153
154 extern cvar_t r_smoothnormals_areaweighting;
155
156 #include "gl_backend.h"
157
158 #include "r_light.h"
159
160 extern rtexture_t *r_texture_blanknormalmap;
161 extern rtexture_t *r_texture_white;
162 extern rtexture_t *r_texture_black;
163 extern rtexture_t *r_texture_notexture;
164 extern rtexture_t *r_texture_whitecube;
165 extern rtexture_t *r_texture_normalizationcube;
166 extern rtexture_t *r_texture_fogattenuation;
167 //extern rtexture_t *r_texture_fogintensity;
168
169 void R_TimeReport(char *name);
170
171 // r_stain
172 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);
173
174 void R_DrawWorldCrosshair(void);
175 void R_Draw2DCrosshair(void);
176
177 void R_CalcBeam_Vertex3f(float *vert, const vec3_t org1, const vec3_t org2, float width);
178 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);
179
180 extern mempool_t *r_main_mempool;
181
182 extern int rsurface_array_size;
183 extern float *rsurface_array_modelvertex3f;
184 extern float *rsurface_array_modelsvector3f;
185 extern float *rsurface_array_modeltvector3f;
186 extern float *rsurface_array_modelnormal3f;
187 extern float *rsurface_array_deformedvertex3f;
188 extern float *rsurface_array_deformedsvector3f;
189 extern float *rsurface_array_deformedtvector3f;
190 extern float *rsurface_array_deformednormal3f;
191 extern float *rsurface_array_color4f;
192 extern float *rsurface_array_texcoord3f;
193
194 typedef enum rsurfmode_e
195 {
196         RSURFMODE_NONE,
197         RSURFMODE_SHOWSURFACES,
198         RSURFMODE_SKY,
199         RSURFMODE_MULTIPASS,
200         RSURFMODE_GLSL
201 }
202 rsurfmode_t;
203
204 extern float *rsurface_vertex3f;
205 extern float *rsurface_svector3f;
206 extern float *rsurface_tvector3f;
207 extern float *rsurface_normal3f;
208 extern float *rsurface_lightmapcolor4f;
209 extern vec3_t rsurface_modelorg;
210 extern qboolean rsurface_generatedvertex;
211 extern const entity_render_t *rsurface_entity;
212 extern const model_t *rsurface_model;
213 extern texture_t *rsurface_texture;
214 extern rtexture_t *rsurface_lightmaptexture;
215 extern rsurfmode_t rsurface_mode;
216
217 void RSurf_ActiveEntity(const entity_render_t *ent, qboolean wantnormals, qboolean wanttangents);
218 void RSurf_CleanUp(void);
219
220 void R_Mesh_ResizeArrays(int newvertices);
221
222 struct entity_render_s;
223 struct texture_s;
224 struct msurface_s;
225 void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t);
226 void R_UpdateAllTextureInfo(entity_render_t *ent);
227 void R_QueueTextureSurfaceList(int texturenumsurfaces, msurface_t **texturesurfacelist);
228 void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces);
229
230 void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generatetangents, int texturenumsurfaces, msurface_t **texturesurfacelist);
231 void RSurf_DrawBatch_Simple(int texturenumsurfaces, msurface_t **texturesurfacelist);
232
233 #define SHADERPERMUTATION_MODE_LIGHTSOURCE (1<<0) // (lightsource) use directional pixel shading from light source (rtlight)
234 #define SHADERPERMUTATION_MODE_LIGHTDIRECTIONMAP_MODELSPACE (1<<1) // (lightmap) use directional pixel shading from texture containing modelspace light directions (deluxemap)
235 #define SHADERPERMUTATION_MODE_LIGHTDIRECTIONMAP_TANGENTSPACE (1<<2) // (lightmap) use directional pixel shading from texture containing tangentspace light directions (deluxemap)
236 #define SHADERPERMUTATION_MODE_LIGHTDIRECTION (1<<3) // (lightmap) use directional pixel shading from fixed light direction (q3bsp)
237 #define SHADERPERMUTATION_GLOW (1<<4) // (lightmap) blend in an additive glow texture
238 #define SHADERPERMUTATION_FOG (1<<5) // tint the color by fog color or black if using additive blend mode
239 #define SHADERPERMUTATION_COLORMAPPING (1<<6) // indicates this is a colormapped skin
240 #define SHADERPERMUTATION_SPECULAR (1<<7) // (lightsource or deluxemapping) render specular effects
241 #define SHADERPERMUTATION_CUBEFILTER (1<<8) // (lightsource) use cubemap light filter
242 #define SHADERPERMUTATION_OFFSETMAPPING (1<<9) // adjust texcoords to roughly simulate a displacement mapped surface
243 #define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING (1<<10) // adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!)
244 #define SHADERPERMUTATION_COUNT (1<<11) // how many permutations are possible
245
246 typedef struct r_glsl_permutation_s
247 {
248         // indicates if we have tried compiling this permutation already
249         qboolean compiled;
250         // 0 if compilation failed
251         int program;
252         int loc_Texture_Normal;
253         int loc_Texture_Color;
254         int loc_Texture_Gloss;
255         int loc_Texture_Cube;
256         int loc_Texture_FogMask;
257         int loc_Texture_Pants;
258         int loc_Texture_Shirt;
259         int loc_Texture_Lightmap;
260         int loc_Texture_Deluxemap;
261         int loc_Texture_Glow;
262         int loc_FogColor;
263         int loc_LightPosition;
264         int loc_EyePosition;
265         int loc_LightColor;
266         int loc_Color_Pants;
267         int loc_Color_Shirt;
268         int loc_FogRangeRecip;
269         int loc_AmbientScale;
270         int loc_DiffuseScale;
271         int loc_SpecularScale;
272         int loc_SpecularPower;
273         int loc_OffsetMapping_Scale;
274         int loc_AmbientColor;
275         int loc_DiffuseColor;
276         int loc_SpecularColor;
277         int loc_LightDir;
278 }
279 r_glsl_permutation_t;
280
281 // information about each possible shader permutation
282 extern r_glsl_permutation_t r_glsl_permutations[SHADERPERMUTATION_COUNT];
283 // currently selected permutation
284 extern r_glsl_permutation_t *r_glsl_permutation;
285
286 void R_GLSL_CompilePermutation(int permutation);
287 int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting);
288 void R_SwitchSurfaceShader(int permutation);
289
290 #endif
291