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.
20 // r_local.h -- private refresh defs
25 #define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
26 // normalizing factor so player model works out to about
27 // 1 pixel per triangle
29 #define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox ()
30 // if bbox is trivially rejected
32 //===========================================================================
41 //===========================================================================
42 // clipped bmodel edges
44 typedef struct bedge_s
47 struct bedge_s
*pnext
;
51 float fv
[3]; // viewspace x, y
54 //===========================================================================
56 extern cvar_t r_draworder
;
57 extern cvar_t r_speeds
;
58 extern cvar_t r_timegraph
;
59 extern cvar_t r_graphheight
;
60 extern cvar_t r_clearcolor
;
61 extern cvar_t r_waterwarp
;
62 extern cvar_t r_fullbright
;
63 extern cvar_t r_drawentities
;
64 extern cvar_t r_aliasstats
;
65 extern cvar_t r_dspeeds
;
66 extern cvar_t r_drawflat
;
67 extern cvar_t r_ambient
;
68 extern cvar_t r_reportsurfout
;
69 extern cvar_t r_maxsurfs
;
70 extern cvar_t r_numsurfs
;
71 extern cvar_t r_reportedgeout
;
72 extern cvar_t r_maxedges
;
73 extern cvar_t r_numedges
;
75 #define XCENTERING (1.0 / 2.0)
76 #define YCENTERING (1.0 / 2.0)
78 #define CLIP_EPSILON 0.001
80 #define BACKFACE_EPSILON 0.01
82 //===========================================================================
84 #define DIST_NOT_SET 98765
86 // !!! if this is changed, it must be changed in asm_draw.h too !!!
87 typedef struct clipplane_s
91 struct clipplane_s
*next
;
97 extern clipplane_t view_clipplanes
[4];
99 //=============================================================================
101 void R_RenderWorld (void);
103 //=============================================================================
105 extern mplane_t screenedge
[4];
107 extern vec3_t r_origin
;
109 extern vec3_t r_entorigin
;
111 extern float screenAspect
;
112 extern float verticalFieldOfView
;
113 extern float xOrigin
, yOrigin
;
115 extern int r_visframecount
;
117 //=============================================================================
119 extern int vstartscan
;
122 void R_ClearPolyList (void);
123 void R_DrawPolyList (void);
126 // current entity info
128 extern qboolean insubmodel
;
129 extern vec3_t r_worldmodelorg
;
132 void R_DrawSprite (void);
133 void R_RenderFace (msurface_t
*fa
, int clipflags
);
134 void R_RenderPoly (msurface_t
*fa
, int clipflags
);
135 void R_RenderBmodelFace (bedge_t
*pedges
, msurface_t
*psurf
);
136 void R_TransformPlane (mplane_t
*p
, float *normal
, float *dist
);
137 void R_TransformFrustum (void);
138 void R_SetSkyFrame (void);
139 void R_DrawSurfaceBlock16 (void);
140 void R_DrawSurfaceBlock8 (void);
141 texture_t
*R_TextureAnimation (texture_t
*base
);
145 void R_DrawSurfaceBlock8_mip0 (void);
146 void R_DrawSurfaceBlock8_mip1 (void);
147 void R_DrawSurfaceBlock8_mip2 (void);
148 void R_DrawSurfaceBlock8_mip3 (void);
152 void R_GenSkyTile (void *pdest
);
153 void R_GenSkyTile16 (void *pdest
);
154 void R_Surf8Patch (void);
155 void R_Surf16Patch (void);
156 void R_DrawSubmodelPolygons (model_t
*pmodel
, int clipflags
);
157 void R_DrawSolidClippedSubmodelPolygons (model_t
*pmodel
);
159 void R_AddPolygonEdges (emitpoint_t
*pverts
, int numverts
, int miplevel
);
160 surf_t
*R_GetSurf (void);
161 void R_AliasDrawModel (alight_t
*plighting
);
162 void R_BeginEdgeFrame (void);
163 void R_ScanEdges (void);
164 void D_DrawSurfaces (void);
165 void R_InsertNewEdges (edge_t
*edgestoadd
, edge_t
*edgelist
);
166 void R_StepActiveU (edge_t
*pedge
);
167 void R_RemoveEdges (edge_t
*pedge
);
169 extern void R_Surf8Start (void);
170 extern void R_Surf8End (void);
171 extern void R_Surf16Start (void);
172 extern void R_Surf16End (void);
173 extern void R_EdgeCodeStart (void);
174 extern void R_EdgeCodeEnd (void);
176 extern void R_RotateBmodel (void);
178 extern int c_faceclip
;
179 extern int r_polycount
;
180 extern int r_wholepolycount
;
182 extern model_t
*cl_worldmodel
;
184 extern int *pfrustum_indexes
[4];
186 // !!! if this is changed, it must be changed in asm_draw.h too !!!
187 #define NEAR_CLIP 0.01
189 extern int ubasestep
, errorterm
, erroradjustup
, erroradjustdown
;
190 extern int vstartscan
;
192 extern fixed16_t sadjust
, tadjust
;
193 extern fixed16_t bbextents
, bbextentt
;
195 #define MAXBVERTINDEXES 1000 // new clipped vertices when clipping bmodels
197 extern mvertex_t
*r_ptverts
, *r_ptvertsmax
;
199 extern vec3_t sbaseaxis
[3], tbaseaxis
[3];
200 extern float entity_rotation
[3][3];
202 extern int reinit_surfcache
;
204 extern int r_currentkey
;
205 extern int r_currentbkey
;
207 typedef struct btofpoly_s
{
212 #define MAX_BTOFPOLYS 5000 // FIXME: tune this
214 extern int numbtofpolys
;
215 extern btofpoly_t
*pbtofpolys
;
217 void R_InitTurb (void);
218 void R_ZDrawSubmodelPolys (model_t
*clmodel
);
220 //=========================================================
222 //=========================================================
224 #define MAXALIASVERTS 2000 // TODO: tune this
225 #define ALIAS_Z_CLIP_PLANE 5
228 extern int a_skinwidth
;
229 extern mtriangle_t
*ptriangles
;
230 extern int numtriangles
;
231 extern aliashdr_t
*paliashdr
;
233 extern float leftclip
, topclip
, rightclip
, bottomclip
;
234 extern int r_acliptype
;
235 extern finalvert_t
*pfinalverts
;
236 extern auxvert_t
*pauxverts
;
238 qboolean
R_AliasCheckBBox (void);
240 //=========================================================
243 #define AMP 8*0x10000
247 //=========================================================
250 void R_DrawParticles (void);
251 void R_InitParticles (void);
252 void R_ClearParticles (void);
253 void R_ReadPointFile_f (void);
254 void R_SurfacePatch (void);
256 extern int r_amodels_drawn
;
257 extern edge_t
*auxedges
;
258 extern int r_numallocatededges
;
259 extern edge_t
*r_edges
, *edge_p
, *edge_max
;
261 extern edge_t
*newedges
[MAXHEIGHT
];
262 extern edge_t
*removeedges
[MAXHEIGHT
];
264 extern int screenwidth
;
266 // FIXME: make stack vars when debugging done
267 extern edge_t edge_head
;
268 extern edge_t edge_tail
;
269 extern edge_t edge_aftertail
;
270 extern int r_bmodelactive
;
271 extern vrect_t
*pconupdate
;
273 extern float aliasxscale
, aliasyscale
, aliasxcenter
, aliasycenter
;
274 extern float r_aliastransition
, r_resfudge
;
276 extern int r_outofsurfaces
;
277 extern int r_outofedges
;
279 extern mvertex_t
*r_pcurrentvertbase
;
280 extern int r_maxvalidedgeoffset
;
282 void R_AliasClipTriangle (mtriangle_t
*ptri
);
284 extern float r_time1
;
285 extern float dp_time1
, dp_time2
, db_time1
, db_time2
, rw_time1
, rw_time2
;
286 extern float se_time1
, se_time2
, de_time1
, de_time2
, dv_time1
, dv_time2
;
287 extern int r_frustum_indexes
[4*6];
288 extern int r_maxsurfsseen
, r_maxedgesseen
, r_cnumsurfs
;
289 extern qboolean r_surfsonstack
;
290 extern cshift_t cshift_water
;
291 extern qboolean r_dowarpold
, r_viewchanged
;
293 extern mleaf_t
*r_viewleaf
, *r_oldviewleaf
;
295 extern vec3_t r_emins
, r_emaxs
;
296 extern mnode_t
*r_pefragtopnode
;
297 extern int r_clipflags
;
298 extern int r_dlightframecount
;
299 extern qboolean r_fov_greater_than_90
;
301 void R_StoreEfrags (efrag_t
**ppefrag
);
302 void R_TimeRefresh_f (void);
303 void R_TimeGraph (void);
304 void R_PrintAliasStats (void);
305 void R_PrintTimes (void);
306 void R_PrintDSpeeds (void);
307 void R_AnimateLight (void);
308 int R_LightPoint (vec3_t p
);
309 void R_SetupFrame (void);
310 void R_cshift_f (void);
311 void R_EmitEdge (mvertex_t
*pv0
, mvertex_t
*pv1
);
312 void R_ClipEdge (mvertex_t
*pv0
, mvertex_t
*pv1
, clipplane_t
*clip
);
313 void R_SplitEntityOnNode2 (mnode_t
*node
);
314 void R_MarkLights (dlight_t
*light
, int bit
, mnode_t
*node
);