2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
25 extern float ixtable[4096];
28 extern void FOG_clear(void);
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);
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);
46 // render profiling stuff
47 extern char r_speeds_string[1024];
48 extern int r_timereport_active;
51 extern cvar_t r_ambient;
52 extern cvar_t gl_flashblend;
55 extern cvar_t r_novis;
57 extern cvar_t r_lerpsprites;
58 extern cvar_t r_lerpmodels;
59 extern cvar_t r_waterscroll;
61 extern cvar_t developer_texturelogging;
63 typedef struct rmesh_s
65 // vertices of this mesh
73 float *texcoordlightmap2f;
75 // triangles of this mesh
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);
92 #define TOP_RANGE 16 // soldier uniform colors
93 #define BOTTOM_RANGE 96
95 //=============================================================================
97 extern cvar_t r_nearclip;
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;
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;
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
124 void R_InitSky (unsigned char *src, int bytesperpixel); // called at level load
126 void R_View_WorldVisibility();
127 void R_DrawParticles(void);
128 void R_DrawExplosions(void);
130 #define gl_solid_format 3
131 #define gl_alpha_format 4
133 int R_CullBox(const vec3_t mins, const vec3_t maxs);
135 #include "r_modules.h"
137 #include "meshqueue.h"
139 #include "r_lerpanim.h"
141 extern cvar_t r_render;
142 extern cvar_t r_waterwarp;
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;
151 extern cvar_t gl_polyblend;
152 extern cvar_t gl_dither;
154 extern cvar_t r_smoothnormals_areaweighting;
156 #include "gl_backend.h"
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;
169 void R_TimeReport(char *name);
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);
174 void R_DrawWorldCrosshair(void);
175 void R_Draw2DCrosshair(void);
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);
180 extern mempool_t *r_main_mempool;
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;
194 typedef enum rsurfmode_e
197 RSURFMODE_SHOWSURFACES,
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;
217 void RSurf_ActiveEntity(const entity_render_t *ent, qboolean wantnormals, qboolean wanttangents);
218 void RSurf_CleanUp(void);
220 void R_Mesh_ResizeArrays(int newvertices);
222 struct entity_render_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);
230 void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generatetangents, int texturenumsurfaces, msurface_t **texturesurfacelist);
231 void RSurf_DrawBatch_Simple(int texturenumsurfaces, msurface_t **texturesurfacelist);
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
246 typedef struct r_glsl_permutation_s
248 // indicates if we have tried compiling this permutation already
250 // 0 if compilation failed
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;
263 int loc_LightPosition;
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;
279 r_glsl_permutation_t;
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;
286 void R_GLSL_CompilePermutation(int permutation);
287 int R_SetupSurfaceShader(const vec3_t lightcolorbase, qboolean modellighting);
288 void R_SwitchSurfaceShader(int permutation);