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.
21 // refresh.h -- public interface to refresh functions
23 // far clip distance for scene
24 extern cvar_t r_farclip;
27 extern void FOG_clear(void);
28 extern float fog_density, fog_red, fog_green, fog_blue;
30 // SHOWLMP stuff (Nehahra)
31 extern void SHOWLMP_decodehide(void);
32 extern void SHOWLMP_decodeshow(void);
33 extern void SHOWLMP_drawall(void);
34 extern void SHOWLMP_clear(void);
36 // render profiling stuff
37 extern qboolean intimerefresh;
38 extern cvar_t r_speeds2;
39 extern char r_speeds2_string[1024];
42 extern vec3_t lightspot;
43 extern cvar_t r_ambient;
44 extern int lightscalebit;
45 extern float lightscale;
47 // model rendering stuff
48 extern float *aliasvert;
49 extern float *aliasvertnorm;
50 extern byte *aliasvertcolor;
53 extern cvar_t r_novis;
55 // model transform stuff
56 extern cvar_t gl_transform;
58 // LordHavoc: 1.0f / N table
59 extern float ixtable[4096];
61 #define TOP_RANGE 16 // soldier uniform colors
62 #define BOTTOM_RANGE 96
64 //=============================================================================
66 typedef struct frameblend_s
73 // LordHavoc: nothing in this structure is persistant, it may be overwritten by the client every frame, for persistant data use entity_lerp_t.
74 typedef struct entity_render_s
76 vec3_t origin; // location
77 vec3_t angles; // orientation
78 float colormod[3]; // color tint for model
79 float alpha; // opacity (alpha) of the model
80 float scale; // size the model is shown
82 model_t *model; // NULL = no model
83 int frame; // current uninterpolated animation frame (for things which do not use interpolation)
84 int colormap; // entity shirt and pants colors
85 int effects; // light, particles, etc
86 int skinnum; // for Alias models
87 int flags; // render flags
89 // these are copied from the persistent data
90 int frame1; // frame that the model is interpolating from
91 int frame2; // frame that the model is interpolating to
92 double framelerp; // interpolation factor, usually computed from frame2time
93 double frame1time; // time frame1 began playing (for framegroup animations)
94 double frame2time; // time frame2 began playing (for framegroup animations)
96 // calculated by the renderer (but not persistent)
97 int visframe; // if visframe == r_framecount, it is visible
98 vec3_t mins, maxs; // calculated during R_AddModelEntities
99 frameblend_t frameblend[4]; // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
103 typedef struct entity_persistent_s
106 vec3_t trail_origin; // trail rendering
107 float trail_time; // trail rendering
109 // interpolated animation
110 int modelindex; // lerp resets when model changes
111 int frame1; // frame that the model is interpolating from
112 int frame2; // frame that the model is interpolating to
113 double framelerp; // interpolation factor, usually computed from frame2time
114 double frame1time; // time frame1 began playing (for framegroup animations)
115 double frame2time; // time frame2 began playing (for framegroup animations)
119 typedef struct entity_s
121 entity_state_t state_baseline; // baseline state (default values)
122 entity_state_t state_previous; // previous state (interpolating from this)
123 entity_state_t state_current; // current state (interpolating to this)
125 entity_persistent_t persistent; // used for regenerating parts of render
127 entity_render_t render; // the only data the renderer should know about
134 int x, y, width, height;
143 extern qboolean hlbsp;
144 //extern qboolean r_cache_thrash; // compatability
145 extern vec3_t modelorg;
146 extern entity_render_t *currentrenderentity;
147 extern int r_framecount;
148 extern mplane_t frustum[4];
149 extern int c_brush_polys, c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights;
157 extern vec3_t vright;
158 extern vec3_t r_origin;
163 extern refdef_t r_refdef;
164 extern mleaf_t *r_viewleaf, *r_oldviewleaf;
165 extern unsigned short d_lightstylevalue[256]; // 8.8 fraction of base light value
167 extern qboolean envmap;
169 extern cvar_t r_drawentities;
170 extern cvar_t r_drawviewmodel;
171 extern cvar_t r_speeds;
172 extern cvar_t r_fullbright;
173 extern cvar_t r_wateralpha;
174 extern cvar_t r_dynamic;
175 extern cvar_t r_waterripple;
177 //extern float r_world_matrix[16];
180 void R_RenderView (void); // must set r_refdef first
182 // LordHavoc: changed this for sake of GLQuake
183 void R_InitSky (byte *src, int bytesperpixel); // called at level load
185 //int R_VisibleCullBox (vec3_t mins, vec3_t maxs);
187 void R_NewMap (void);
189 #include "r_decals.h"
191 void R_ParseParticleEffect (void);
192 void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
193 void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
194 void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
195 void R_SparkShower (vec3_t org, vec3_t dir, int count);
196 void R_BloodPuff (vec3_t org, vec3_t vel, int count);
197 void R_FlameCube (vec3_t mins, vec3_t maxs, int count);
198 void R_Flames (vec3_t org, vec3_t vel, int count);
200 void R_EntityParticles (entity_t *ent);
201 void R_BlobExplosion (vec3_t org);
202 void R_ParticleExplosion (vec3_t org, int smoke);
203 void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
204 void R_LavaSplash (vec3_t org);
205 void R_TeleportSplash (vec3_t org);
207 void R_NewExplosion(vec3_t org);
209 void R_PushDlights (void);
210 void R_DrawWorld (void);
211 //void R_RenderDlights (void);
212 void R_DrawParticles (void);
213 void R_MoveParticles (void);
214 void R_DrawExplosions (void);
215 void R_MoveExplosions (void);
219 // LordHavoc: vertex transform
220 #include "transform.h"
222 // LordHavoc: transparent polygon system
225 #define gl_solid_format 3
226 #define gl_alpha_format 4
230 // LordHavoc: was a major time waster
231 #define R_CullBox(mins,maxs) (frustum[0].BoxOnPlaneSideFunc(mins, maxs, &frustum[0]) == 2 || frustum[1].BoxOnPlaneSideFunc(mins, maxs, &frustum[1]) == 2 || frustum[2].BoxOnPlaneSideFunc(mins, maxs, &frustum[2]) == 2 || frustum[3].BoxOnPlaneSideFunc(mins, maxs, &frustum[3]) == 2)
232 #define R_NotCulledBox(mins,maxs) (frustum[0].BoxOnPlaneSideFunc(mins, maxs, &frustum[0]) != 2 && frustum[1].BoxOnPlaneSideFunc(mins, maxs, &frustum[1]) != 2 && frustum[2].BoxOnPlaneSideFunc(mins, maxs, &frustum[2]) != 2 && frustum[3].BoxOnPlaneSideFunc(mins, maxs, &frustum[3]) != 2)
234 extern qboolean fogenabled;
235 extern vec3_t fogcolor;
236 extern vec_t fogdensity;
237 //#define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_origin[0]) * vpn[0] + ((v)[1] - r_origin[1]) * vpn[1] + ((v)[2] - r_origin[2]) * vpn[2])*(((v)[0] - r_origin[0]) * vpn[0] + ((v)[1] - r_origin[1]) * vpn[1] + ((v)[2] - r_origin[2]) * vpn[2]))))
238 #define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_origin[0])*((v)[0] - r_origin[0])+((v)[1] - r_origin[1])*((v)[1] - r_origin[1])+((v)[2] - r_origin[2])*((v)[2] - r_origin[2])))))
239 #define calcfogbyte(v) ((byte) (bound(0, ((int) ((float) (calcfog((v)) * 255.0f))), 255)))
241 #include "r_modules.h"
243 extern qboolean lighthalf;
245 #include "r_lerpanim.h"
247 void GL_LockArray(int first, int count);
248 void GL_UnlockArray(void);
250 void R_DrawBrushModel (void);
251 void R_DrawAliasModel (void);
252 void R_DrawSpriteModel (void);
254 void R_ClipSprite (void);
255 void R_Entity_Callback(void *data, void *junk);
257 extern cvar_t r_render;
258 extern cvar_t r_upload;
262 // if contents is not zero, it will impact on content changes
263 // (leafs matching contents are considered empty, others are solid)
264 extern int traceline_endcontents; // set by TraceLine
265 float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int contents);