1 /* 2 * r_local.h -- private refresh defs 3 * 4 * Copyright (C) 1996-1997 Id Software, Inc. 5 * Copyright (C) 1997-1998 Raven Software Corp. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or (at 10 * your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 * 16 * See the GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with this program; if not, write to the Free Software Foundation, Inc., 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #ifndef R_LOCAL_H 24 #define R_LOCAL_H 25 26 #ifndef GLQUAKE 27 28 #include "r_shared.h" 29 30 31 #define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0) 32 // normalizing factor so player model works out 33 // to about 1 pixel per triangle 34 35 #define BMODEL_FULLY_CLIPPED 0x10 36 // value returned by R_BmodelCheckBBox () 37 // if bbox is trivially rejected 38 39 //=========================================================================== 40 // viewmodel lighting 41 42 typedef struct { 43 int ambientlight; 44 int shadelight; 45 float *plightvec; 46 } alight_t; 47 48 //=========================================================================== 49 // clipped bmodel edges 50 51 typedef struct bedge_s 52 { 53 mvertex_t *v[2]; 54 struct bedge_s *pnext; 55 } bedge_t; 56 57 typedef struct { 58 float fv[3]; // viewspace x, y 59 } auxvert_t; 60 61 //=========================================================================== 62 63 extern cvar_t r_draworder; 64 extern cvar_t r_speeds; 65 extern cvar_t r_timegraph; 66 extern cvar_t r_graphheight; 67 extern cvar_t r_clearcolor; 68 extern cvar_t r_waterwarp; 69 extern cvar_t r_fullbright; 70 extern cvar_t r_drawentities; 71 extern cvar_t r_aliasstats; 72 extern cvar_t r_dspeeds; 73 extern cvar_t r_drawflat; 74 extern cvar_t r_ambient; 75 extern cvar_t r_reportsurfout; 76 extern cvar_t r_maxsurfs; 77 extern cvar_t r_numsurfs; 78 extern cvar_t r_reportedgeout; 79 extern cvar_t r_maxedges; 80 extern cvar_t r_numedges; 81 extern cvar_t r_aliasmip; 82 extern cvar_t r_transwater; 83 #ifdef H2W 84 extern cvar_t r_teamcolor; 85 #endif 86 extern cvar_t r_texture_external; 87 extern cvar_t r_dynamic; 88 89 #define XCENTERING (1.0 / 2.0) 90 #define YCENTERING (1.0 / 2.0) 91 92 #define CLIP_EPSILON 0.001 93 94 #define BACKFACE_EPSILON 0.01 95 96 //=========================================================================== 97 98 #define DIST_NOT_SET 98765 99 100 // !!! if this is changed, it must be changed in asm_draw.h too !!! 101 typedef struct clipplane_s 102 { 103 vec3_t normal; 104 float dist; 105 struct clipplane_s *next; 106 byte leftedge; 107 byte rightedge; 108 byte reserved[2]; 109 } clipplane_t; 110 111 extern clipplane_t view_clipplanes[4]; 112 113 //============================================================================= 114 115 void R_RenderWorld (void); 116 117 //============================================================================= 118 119 extern mplane_t screenedge[4]; 120 121 ASM_LINKAGE_BEGIN 122 extern vec3_t r_origin; 123 ASM_LINKAGE_END 124 125 extern vec3_t r_entorigin; 126 127 extern float screenAspect; 128 extern float verticalFieldOfView; 129 extern float xOrigin, yOrigin; 130 131 extern int r_visframecount; 132 133 //============================================================================= 134 135 // 136 // current entity info 137 // 138 extern qboolean insubmodel; 139 140 141 void R_DrawSprite (void); 142 void R_RenderFace (msurface_t *fa, int clipflags); 143 void R_RenderPoly (msurface_t *fa, int clipflags); 144 void R_DrawPolyList (void); 145 void R_ClearPolyList (void); 146 void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf); 147 void R_RotateBmodel (void); 148 void R_TransformPlane (mplane_t *p, float *normal, float *dist); 149 void R_TransformFrustum (void); 150 void R_SetSkyFrame (void); 151 texture_t *R_TextureAnimation (texture_t *base); 152 153 void R_GenSkyTile (void *pdest); 154 void R_GenSkyTile16 (void *pdest); 155 156 void R_DrawSubmodelPolygons (qmodel_t *pmodel, int clipflags); 157 void R_DrawSolidClippedSubmodelPolygons (qmodel_t *pmodel); 158 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 (qboolean Translucent); 164 165 166 ASM_LINKAGE_BEGIN 167 168 #if id386 169 void R_Surf8Patch (void); 170 void R_Surf16Patch (void); 171 void R_SurfacePatch (void); 172 173 void R_Surf8Start (void); 174 void R_Surf8End (void); 175 void R_Surf16Start (void); 176 void R_Surf16End (void); 177 void R_EdgeCodeStart (void); 178 void R_EdgeCodeEnd (void); 179 void R_EdgeCodeStartT (void); 180 void R_EdgeCodeEndT (void); 181 182 void R_DrawSurfaceBlock16 (void); 183 void R_DrawSurfaceBlock8_mip0 (void); 184 void R_DrawSurfaceBlock8_mip1 (void); 185 void R_DrawSurfaceBlock8_mip2 (void); 186 void R_DrawSurfaceBlock8_mip3 (void); 187 188 void R_GenerateSpans (void); 189 void R_GenerateTSpans (void); 190 void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist); 191 void R_RemoveEdges (edge_t *pedge); 192 void R_StepActiveU (edge_t *pedge); 193 194 void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out); 195 void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out); 196 void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out); 197 void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out); 198 199 void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts); 200 201 void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip); 202 #endif 203 204 #if id68k 205 void R_DrawSurfaceBlock16 (void); 206 void R_DrawSurfaceBlock8_mip0 (void); 207 void R_DrawSurfaceBlock8_mip1 (void); 208 void R_DrawSurfaceBlock8_mip2 (void); 209 void R_DrawSurfaceBlock8_mip3 (void); 210 211 void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts); 212 213 void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip); 214 #endif 215 216 ASM_LINKAGE_END 217 218 void R_AliasProjectFinalVert (finalvert_t *, auxvert_t *); 219 220 221 extern int c_faceclip; 222 extern int r_polycount; 223 extern int r_wholepolycount; 224 225 extern int *pfrustum_indexes[4]; 226 227 // !!! if this is changed, it must be changed in asm_draw.h too !!! 228 #define NEAR_CLIP 0.01 229 230 ASM_LINKAGE_BEGIN 231 extern int ubasestep, errorterm, erroradjustup, erroradjustdown; 232 extern int vstartscan; 233 234 extern fixed16_t sadjust, tadjust; 235 extern fixed16_t bbextents, bbextentt; 236 237 ASM_LINKAGE_END 238 239 #define MAXBVERTINDEXES 1000 // new clipped vertices when clipping bmodels 240 // to the world BSP 241 extern mvertex_t *r_ptverts, *r_ptvertsmax; 242 243 extern vec3_t sbaseaxis[3], tbaseaxis[3]; 244 extern float entity_rotation[3][3]; 245 246 extern int r_currentkey; 247 extern int r_currentbkey; 248 249 typedef struct btofpoly_s 250 { 251 int clipflags; 252 msurface_t *psurf; 253 } btofpoly_t; 254 255 #define MAX_BTOFPOLYS 5000 // FIXME: tune this 256 257 extern int numbtofpolys; 258 extern btofpoly_t *pbtofpolys; 259 260 void R_ZDrawSubmodelPolys (qmodel_t *clmodel); 261 262 //========================================================= 263 // Alias models 264 //========================================================= 265 266 #define MAXALIASVERTS 2000 // TODO: tune this 267 #define ALIAS_Z_CLIP_PLANE 5 268 269 extern int numverts; 270 extern mtriangle_t *ptriangles; 271 extern int numtriangles; 272 extern aliashdr_t *paliashdr; 273 extern newmdl_t *pmdl; 274 extern float leftclip, topclip, rightclip, bottomclip; 275 extern int r_acliptype; 276 extern finalvert_t *pfinalverts; 277 extern auxvert_t *pauxverts; 278 279 qboolean R_AliasCheckBBox (void); 280 281 //========================================================= 282 // turbulence stuff 283 284 #define AMP 8*0x10000 285 #define AMP2 3 286 #define SPEED 20 287 288 //========================================================= 289 290 void R_ReadPointFile_f (void); 291 292 extern int r_amodels_drawn; 293 extern edge_t *auxedges; 294 extern int r_numallocatededges; 295 ASM_LINKAGE_BEGIN 296 extern edge_t *r_edges, *edge_p, *edge_max; 297 298 extern edge_t *newedges[MAXHEIGHT]; 299 extern edge_t *removeedges[MAXHEIGHT]; 300 301 extern int screenwidth; 302 303 // FIXME: make stack vars when debugging done 304 extern edge_t edge_head; 305 extern edge_t edge_tail; 306 extern edge_t edge_aftertail; 307 extern int r_bmodelactive; 308 ASM_LINKAGE_END 309 310 extern vrect_t *pconupdate; 311 312 ASM_LINKAGE_BEGIN 313 extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter; 314 ASM_LINKAGE_END 315 extern float r_aliastransition, r_resfudge; 316 317 extern int r_outofsurfaces; 318 extern int r_outofedges; 319 320 extern mvertex_t *r_pcurrentvertbase; 321 extern int r_maxvalidedgeoffset; 322 323 void R_AliasClipTriangle (mtriangle_t *ptri); 324 325 extern float r_time1; 326 extern float dp_time1, dp_time2, db_time1, db_time2, rw_time1, rw_time2; 327 extern float se_time1, se_time2, de_time1, de_time2, dv_time1, dv_time2; 328 extern int r_frustum_indexes[4*6]; 329 extern int r_maxsurfsseen, r_maxedgesseen, r_cnumsurfs; 330 extern qboolean r_surfsonstack; 331 extern cshift_t cshift_water; 332 extern qboolean r_dowarpold, r_viewchanged; 333 334 extern float r_lasttime1; 335 336 extern mleaf_t *r_viewleaf, *r_oldviewleaf; 337 338 extern vec3_t r_emins, r_emaxs; 339 extern mnode_t *r_pefragtopnode; 340 extern int r_clipflags; 341 extern int r_dlightframecount; 342 extern qboolean r_fov_greater_than_90; 343 344 ASM_LINKAGE_BEGIN 345 extern int FoundTrans; 346 extern int TransCount; 347 ASM_LINKAGE_END 348 349 void R_StoreEfrags (efrag_t **ppefrag); 350 void R_TimeRefresh_f (void); 351 void R_TimeGraph (void); 352 void R_PrintAliasStats (void); 353 void R_PrintTimes (void); 354 void R_PrintDSpeeds (void); 355 void R_AnimateLight (void); 356 int R_LightPoint (vec3_t p); 357 int *R_LightPointColour (vec3_t p); 358 void R_SetupFrame (void); 359 void R_cshift_f (void); 360 void R_SplitEntityOnNode2 (mnode_t *node); 361 void R_MarkLights (dlight_t *light, int bit, mnode_t *node); 362 363 #endif /* !GLQUAKE */ 364 365 #endif /* R_LOCAL_H */ 366 367