]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - render.h
rewrote RecursiveHullCheck, no longer gets stuck on angle changes, and is generally...
[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 // refresh.h -- public interface to refresh functions
22
23 // far clip distance for scene
24 extern cvar_t r_farclip;
25
26 // fog stuff
27 extern void FOG_clear(void);
28 extern float fog_density, fog_red, fog_green, fog_blue;
29
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);
35
36 // render profiling stuff
37 extern qboolean intimerefresh;
38 extern cvar_t r_speeds2;
39 extern char r_speeds2_string[1024];
40
41 // lighting stuff
42 extern vec3_t lightspot;
43 extern cvar_t r_ambient;
44 extern int lightscalebit;
45 extern float lightscale;
46
47 // model rendering stuff
48 extern float *aliasvert;
49 extern float *aliasvertnorm;
50 extern byte *aliasvertcolor;
51
52 // vis stuff
53 extern cvar_t r_novis;
54
55 // model transform stuff
56 extern cvar_t gl_transform;
57
58 // LordHavoc: 1.0f / N table
59 extern float ixtable[4096];
60
61 #define TOP_RANGE               16                      // soldier uniform colors
62 #define BOTTOM_RANGE    96
63
64 //=============================================================================
65
66 typedef struct frameblend_s
67 {
68         int frame;
69         float lerp;
70 }
71 frameblend_t;
72
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
75 {
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
81
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
88
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)
95
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
100 }
101 entity_render_t;
102
103 typedef struct entity_persistent_s
104 {
105         // particles
106         vec3_t  trail_origin;   // trail rendering
107         float   trail_time;             // trail rendering
108
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)
116 }
117 entity_persistent_t;
118
119 typedef struct entity_s
120 {
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)
124
125         entity_persistent_t persistent; // used for regenerating parts of render
126
127         entity_render_t render; // the only data the renderer should know about
128 }
129 entity_t;
130
131 typedef struct
132 {
133         // area to render in
134         int             x, y, width, height;
135         float   fov_x, fov_y;
136
137         // view point
138         vec3_t  vieworg;
139         vec3_t  viewangles;
140 }
141 refdef_t;
142
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;
150
151
152 //
153 // view origin
154 //
155 extern  vec3_t  vup;
156 extern  vec3_t  vpn;
157 extern  vec3_t  vright;
158 extern  vec3_t  r_origin;
159
160 //
161 // screen size info
162 //
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
166
167 extern  qboolean        envmap;
168
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;
176
177 //extern        float   r_world_matrix[16];
178
179 void R_Init (void);
180 void R_RenderView (void); // must set r_refdef first
181
182 // LordHavoc: changed this for sake of GLQuake
183 void R_InitSky (byte *src, int bytesperpixel); // called at level load
184
185 //int R_VisibleCullBox (vec3_t mins, vec3_t maxs);
186
187 void R_NewMap (void);
188
189 #include "r_decals.h"
190
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);
199
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);
206
207 void R_NewExplosion(vec3_t org);
208
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);
216
217 #include "r_clip.h"
218
219 // LordHavoc: vertex transform
220 #include "transform.h"
221
222 // LordHavoc: transparent polygon system
223 #include "gl_poly.h"
224
225 #define gl_solid_format 3
226 #define gl_alpha_format 4
227
228 //#define PARANOID
229
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)
233
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)))
240
241 #include "r_modules.h"
242
243 extern qboolean lighthalf;
244
245 #include "r_lerpanim.h"
246
247 void GL_LockArray(int first, int count);
248 void GL_UnlockArray(void);
249
250 void R_DrawBrushModel (void);
251 void R_DrawAliasModel (void);
252 void R_DrawSpriteModel (void);
253
254 void R_ClipSprite (void);
255 void R_Entity_Callback(void *data, void *junk);
256
257 extern cvar_t r_render;
258 extern cvar_t r_upload;
259 extern cvar_t r_ser;
260 #include "image.h"
261
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);