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.
24 qboolean r_cache_thrash; // compatability
26 vec3_t modelorg, r_entorigin;
27 entity_t *currententity;
29 int r_framecount; // used for dlight push checking
33 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;
35 qboolean envmap; // true during envmap command capture
37 // LordHavoc: moved all code related to particles into r_part.c
38 //int particletexture; // little dot for particles
39 //int playertextures; // up to 16 color translated skins
49 float r_world_matrix[16];
50 float r_base_world_matrix[16];
57 mleaf_t *r_viewleaf, *r_oldviewleaf;
59 unsigned short d_lightstylevalue[256]; // 8.8 fraction of base light value
63 void R_MarkLeaves (void);
65 //cvar_t r_norefresh = {0, "r_norefresh","0"};
66 cvar_t r_drawentities = {0, "r_drawentities","1"};
67 cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
68 cvar_t r_speeds = {0, "r_speeds","0"};
69 cvar_t r_speeds2 = {0, "r_speeds2","0"};
70 cvar_t r_fullbright = {0, "r_fullbright","0"};
71 //cvar_t r_lightmap = {0, "r_lightmap","0"};
72 cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1"};
73 cvar_t r_dynamic = {CVAR_SAVE, "r_dynamic","1"};
74 cvar_t r_waterripple = {CVAR_SAVE, "r_waterripple","0"};
75 cvar_t r_fullbrights = {CVAR_SAVE, "r_fullbrights", "1"};
77 cvar_t gl_lightmode = {CVAR_SAVE, "gl_lightmode", "1"}; // LordHavoc: overbright lighting
78 //cvar_t r_dynamicbothsides = {CVAR_SAVE, "r_dynamicbothsides", "1"}; // LordHavoc: can disable dynamic lighting of backfaces, but quake maps are weird so it doesn't always work right...
79 cvar_t r_farclip = {0, "r_farclip", "6144"}; // FIXME: make this go away (calculate based on farthest visible object/polygon)
81 cvar_t gl_fogenable = {0, "gl_fogenable", "0"};
82 cvar_t gl_fogdensity = {0, "gl_fogdensity", "0.25"};
83 cvar_t gl_fogred = {0, "gl_fogred","0.3"};
84 cvar_t gl_foggreen = {0, "gl_foggreen","0.3"};
85 cvar_t gl_fogblue = {0, "gl_fogblue","0.3"};
86 cvar_t gl_fogstart = {0, "gl_fogstart", "0"};
87 cvar_t gl_fogend = {0, "gl_fogend","0"};
88 cvar_t glfog = {0, "glfog", "0"};
91 int R_VisibleCullBox (vec3_t mins, vec3_t maxs)
94 mnode_t *nodestack[8192], *node;
97 node = cl.worldmodel->nodes;
99 if (node->contents < 0)
101 if (((mleaf_t *)node)->visframe == r_framecount)
103 if (R_CullBox(mins, maxs))
109 node = nodestack[--stack];
113 sides = BOX_ON_PLANE_SIDE(mins, maxs, node->plane);
115 // recurse down the contacted sides
120 // put second child on the stack for later examination
121 nodestack[stack++] = node->children[1];
122 node = node->children[0];
127 node = node->children[0];
132 node = node->children[1];
141 float fog_density, fog_red, fog_green, fog_blue;
143 qboolean oldgl_fogenable;
144 void FOG_framebegin(void)
148 // if (!Nehahrademcompatibility)
149 // gl_fogenable.value = 0;
150 if (gl_fogenable.value)
152 oldgl_fogenable = true;
153 fog_density = gl_fogdensity.value;
154 fog_red = gl_fogred.value;
155 fog_green = gl_foggreen.value;
156 fog_blue = gl_fogblue.value;
158 else if (oldgl_fogenable)
160 oldgl_fogenable = false;
169 fogcolor[0] = fog_red = bound(0.0f, fog_red , 1.0f);
170 fogcolor[1] = fog_green = bound(0.0f, fog_green, 1.0f);
171 fogcolor[2] = fog_blue = bound(0.0f, fog_blue , 1.0f);
185 // LordHavoc: Borland C++ 5.0 was choking on this line, stupid compiler...
186 //GLfloat colors[4] = {(GLfloat) gl_fogred.value, (GLfloat) gl_foggreen.value, (GLfloat) gl_fogblue.value, (GLfloat) 1};
189 colors[1] = fog_green;
190 colors[2] = fog_blue;
199 glFogi (GL_FOG_MODE, GL_EXP2);
200 glFogf (GL_FOG_DENSITY, (GLfloat) fog_density / 100);
201 glFogfv (GL_FOG_COLOR, colors);
212 fogdensity = -4000.0f / (fog_density * fog_density);
213 // fog color was already set
220 void FOG_frameend(void)
230 Cvar_Set("gl_fogenable", "0");
231 Cvar_Set("gl_fogdensity", "0.2");
232 Cvar_Set("gl_fogred", "0.3");
233 Cvar_Set("gl_foggreen", "0.3");
234 Cvar_Set("gl_fogblue", "0.3");
236 fog_density = fog_red = fog_green = fog_blue = 0.0f;
239 void FOG_registercvars(void)
241 Cvar_RegisterVariable (&glfog);
244 Cvar_RegisterVariable (&gl_fogenable);
245 Cvar_RegisterVariable (&gl_fogdensity);
246 Cvar_RegisterVariable (&gl_fogred);
247 Cvar_RegisterVariable (&gl_foggreen);
248 Cvar_RegisterVariable (&gl_fogblue);
249 Cvar_RegisterVariable (&gl_fogstart);
250 Cvar_RegisterVariable (&gl_fogend);
254 void gl_main_start(void)
258 void gl_main_shutdown(void)
262 void gl_main_newmap(void)
266 void GL_Main_Init(void)
270 // LordHavoc: setup 1.0f / N table for quick recipricols of integers
272 for (a = 1;a < 4096;a++)
273 ixtable[a] = 1.0f / a;
274 Cvar_RegisterVariable (&r_drawentities);
275 Cvar_RegisterVariable (&r_drawviewmodel);
276 Cvar_RegisterVariable (&r_speeds);
277 Cvar_RegisterVariable (&r_speeds2);
278 Cvar_RegisterVariable (&gl_lightmode);
279 // Cvar_RegisterVariable (&r_dynamicwater);
280 // Cvar_RegisterVariable (&r_dynamicbothsides);
281 Cvar_RegisterVariable (&r_fullbrights);
282 Cvar_RegisterVariable (&r_wateralpha);
283 Cvar_RegisterVariable (&r_dynamic);
284 Cvar_RegisterVariable (&r_waterripple);
285 Cvar_RegisterVariable (&r_farclip);
287 Cvar_SetValue("r_fullbrights", 0);
288 // if (gl_vendor && strstr(gl_vendor, "3Dfx"))
289 // gl_lightmode.value = 0;
290 Cvar_RegisterVariable (&r_fullbright);
291 R_RegisterModule("GL_Main", gl_main_start, gl_main_shutdown, gl_main_newmap);
294 extern void GL_Draw_Init(void);
295 extern void GL_Main_Init(void);
296 extern void GL_Models_Init(void);
297 extern void GL_Poly_Init(void);
298 extern void GL_Surf_Init(void);
299 extern void GL_Screen_Init(void);
300 extern void GL_Misc_Init(void);
301 extern void R_Crosshairs_Init(void);
302 extern void R_Light_Init(void);
303 extern void R_Particles_Init(void);
304 extern void R_Explosion_Init(void);
305 extern void CL_Effects_Init(void);
306 extern void R_Clip_Init(void);
307 extern void ui_init(void);
309 void Render_Init(void)
311 R_Modules_Shutdown();
335 extern char *ENGINE_EXTENSIONS;
338 gl_vendor = glGetString (GL_VENDOR);
339 Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
340 gl_renderer = glGetString (GL_RENDERER);
341 Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
343 gl_version = glGetString (GL_VERSION);
344 Con_Printf ("GL_VERSION: %s\n", gl_version);
345 gl_extensions = glGetString (GL_EXTENSIONS);
346 Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
348 // Con_Printf ("%s %s\n", gl_renderer, gl_version);
350 VID_CheckMultitexture();
353 // LordHavoc: report supported extensions
354 Con_Printf ("\nengine extensions: %s\n", ENGINE_EXTENSIONS);
356 glCullFace(GL_FRONT);
357 glEnable(GL_TEXTURE_2D);
358 // glDisable(GL_ALPHA_TEST);
359 glAlphaFunc(GL_GREATER, 0.5);
361 // glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
366 void R_RotateForEntity (entity_t *e)
368 glTranslatef (e->origin[0], e->origin[1], e->origin[2]);
370 glRotatef (e->angles[1], 0, 0, 1);
371 glRotatef (-e->angles[0], 0, 1, 0);
372 glRotatef (e->angles[2], 1, 0, 0);
374 glScalef (e->scale, e->scale, e->scale); // LordHavoc: model scale
378 // LordHavoc: shading stuff
384 //==================================================================================
386 void R_LerpUpdate(entity_t *ent)
389 frame = ent->render.frame;
390 if (ent->render.model && ent->render.frame >= ent->render.model->numframes)
392 Con_Printf("R_LerpUpdate: no such frame%6i in \"%s\"\n", ent->render.frame, ent->render.model->name);
396 if (ent->render.lerp_model != ent->render.model)
398 // reset all interpolation information
399 ent->render.lerp_model = ent->render.model;
400 ent->render.frame1 = ent->render.frame2 = frame;
401 ent->render.frame1start = ent->render.frame2start = cl.time;
402 ent->render.framelerp = 1;
403 ent->render.lerp_starttime = 0;
405 else if (ent->render.frame2 != frame)
407 // transition to new frame
408 ent->render.frame1 = ent->render.frame2;
409 ent->render.frame1start = ent->render.frame2start;
410 ent->render.frame2 = frame;
411 ent->render.frame2start = cl.time;
412 ent->render.framelerp = 0;
413 ent->render.lerp_starttime = cl.time;
417 // lerp_starttime < 0 is used to prevent changing of framelerp
418 if (ent->render.lerp_starttime >= 0)
421 ent->render.framelerp = (cl.time - ent->render.lerp_starttime) * 10;
422 ent->render.framelerp = bound(0, ent->render.framelerp, 1);
428 void R_PrepareEntities (void)
433 // this updates entities that are supposed to be view relative
434 for (i = 0;i < cl_numvisedicts;i++)
436 ent = cl_visedicts[i];
438 if (ent->render.flags & RENDER_VIEWMODEL)
440 // remove flag so it will not be repeated incase RelinkEntities is not called again for a while
441 ent->render.flags -= RENDER_VIEWMODEL;
443 VectorCopy(ent->render.origin, v);
444 ent->render.origin[0] = v[0] * vpn[0] + v[1] * vright[0] + v[2] * vup[0] + r_origin[0];
445 ent->render.origin[1] = v[0] * vpn[1] + v[1] * vright[1] + v[2] * vup[1] + r_origin[1];
446 ent->render.origin[2] = v[0] * vpn[2] + v[1] * vright[2] + v[2] * vup[2] + r_origin[2];
448 VectorAdd(ent->render.angles, r_refdef.viewangles, ent->render.angles);
453 void R_Entity_Callback(void *data, void *junk)
455 ((entity_t *)data)->render.visframe = r_framecount;
458 void R_AddModelEntities (void)
462 frameblend_t blend[4];
464 if (!r_drawentities.value)
467 for (i = 0;i < cl_numvisedicts;i++)
469 currententity = cl_visedicts[i];
470 if (currententity->render.model->type == mod_brush)
472 modelalpha = currententity->render.alpha;
473 R_DrawBrushModel (currententity);
475 else if (currententity->render.model->type == mod_alias)
477 VectorAdd(currententity->render.origin, currententity->render.model->mins, mins);
478 VectorAdd(currententity->render.origin, currententity->render.model->maxs, maxs);
479 R_Clip_AddBox(mins, maxs, R_Entity_Callback, currententity, NULL);
481 else if (currententity->render.model->type == mod_sprite)
483 R_LerpUpdate(currententity);
484 R_LerpAnimation(currententity->render.model, currententity->render.frame1, currententity->render.frame2, currententity->render.frame1start, currententity->render.frame2start, currententity->render.framelerp, blend);
485 R_ClipSprite(currententity, blend);
496 void R_DrawEntitiesOnList1 (void)
500 if (!r_drawentities.value)
503 for (i = 0;i < cl_numvisedicts;i++)
505 if (cl_visedicts[i]->render.visframe != r_framecount)
507 if (cl_visedicts[i]->render.model->type != mod_brush)
509 currententity = cl_visedicts[i];
510 modelalpha = currententity->render.alpha;
512 R_DrawBrushModel (currententity);
517 void R_DrawModels (void)
520 frameblend_t blend[4];
521 // vec3_t mins, maxs;
523 if (!r_drawentities.value)
526 for (i = 0;i < cl_numvisedicts;i++)
528 if (cl_visedicts[i]->render.visframe != r_framecount)
530 currententity = cl_visedicts[i];
531 if (currententity->render.model->type != mod_alias && currententity->render.model->type != mod_sprite)
534 modelalpha = currententity->render.alpha;
536 if (currententity->render.model->type == mod_alias)
538 // only lerp models here because sprites were already lerped for their clip polygon
539 R_LerpUpdate(currententity);
540 R_LerpAnimation(currententity->render.model, currententity->render.frame1, currententity->render.frame2, currententity->render.frame1start, currententity->render.frame2start, currententity->render.framelerp, blend);
541 R_DrawAliasModel (currententity, true, modelalpha, currententity->render.model, blend, currententity->render.skinnum, currententity->render.origin, currententity->render.angles, currententity->render.scale, currententity->render.effects, currententity->render.model->flags, currententity->render.colormap);
543 else //if (currententity->render.model->type == mod_sprite)
546 R_LerpAnimation(currententity->render.model, currententity->render.frame1, currententity->render.frame2, currententity->render.frame1start, currententity->render.frame2start, currententity->render.framelerp, blend);
547 R_DrawSpriteModel (currententity, blend);
551 VectorAdd(cl_visedicts[i]->render.origin, cl_visedicts[i]->render.model->mins, mins);
552 VectorAdd(cl_visedicts[i]->render.origin, cl_visedicts[i]->render.model->maxs, maxs);
554 switch (cl_visedicts[i]->render.model->type)
557 R_Clip_AddBox(mins, maxs, R_DrawModelCallback, cl_visedicts[i], NULL);
560 R_Clip_AddBox(mins, maxs, R_DrawSpriteCallback, cl_visedicts[i], NULL);
572 void R_DrawViewModel (void)
574 frameblend_t blend[4];
576 if (!r_drawviewmodel.value || chase_active.value || envmap || !r_drawentities.value || cl.items & IT_INVISIBILITY || cl.stats[STAT_HEALTH] <= 0 || !cl.viewent.render.model)
579 currententity = &cl.viewent;
580 currententity->render.alpha = modelalpha = cl_entities[cl.viewentity].render.alpha; // LordHavoc: if the player is transparent, so is the gun
581 currententity->render.effects = cl_entities[cl.viewentity].render.effects;
582 currententity->render.scale = 1;
583 VectorCopy(cl_entities[cl.viewentity].render.colormod, currententity->render.colormod);
585 R_LerpUpdate(currententity);
586 R_LerpAnimation(currententity->render.model, currententity->render.frame1, currententity->render.frame2, currententity->render.frame1start, currententity->render.frame2start, currententity->render.framelerp, blend);
588 // hack the depth range to prevent view model from poking into walls
589 glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
590 R_DrawAliasModel (currententity, false, modelalpha, currententity->render.model, blend, currententity->render.skinnum, currententity->render.origin, currententity->render.angles, currententity->render.scale, currententity->render.effects, currententity->render.model->flags, currententity->render.colormap);
591 glDepthRange (gldepthmin, gldepthmax);
594 void R_DrawBrushModel (entity_t *e);
596 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
598 void R_SetFrustum (void)
602 // LordHavoc: note to all quake engine coders, this code was making the
603 // view frustum taller than it should have been (it assumed the view is
604 // square; it is not square), so I disabled it
606 if (r_refdef.fov_x == 90)
608 // front side is visible
610 VectorAdd (vpn, vright, frustum[0].normal);
611 VectorSubtract (vpn, vright, frustum[1].normal);
613 VectorAdd (vpn, vup, frustum[2].normal);
614 VectorSubtract (vpn, vup, frustum[3].normal);
619 // rotate VPN right by FOV_X/2 degrees
620 RotatePointAroundVector( frustum[0].normal, vup, vpn, -(90-r_refdef.fov_x / 2 ) );
621 // rotate VPN left by FOV_X/2 degrees
622 RotatePointAroundVector( frustum[1].normal, vup, vpn, 90-r_refdef.fov_x / 2 );
623 // rotate VPN up by FOV_X/2 degrees
624 RotatePointAroundVector( frustum[2].normal, vright, vpn, 90-r_refdef.fov_y / 2 );
625 // rotate VPN down by FOV_X/2 degrees
626 RotatePointAroundVector( frustum[3].normal, vright, vpn, -( 90 - r_refdef.fov_y / 2 ) );
629 for (i=0 ; i<4 ; i++)
631 frustum[i].type = PLANE_ANYZ;
632 frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
633 // frustum[i].signbits = SignbitsForPlane (&frustum[i]);
634 PlaneClassify(&frustum[i]);
638 void R_AnimateLight (void);
639 void V_CalcBlend (void);
646 void R_SetupFrame (void)
648 // don't allow cheats in multiplayer
649 if (cl.maxclients > 1)
651 Cvar_Set ("r_fullbright", "0");
652 Cvar_Set ("r_ambient", "0");
657 // build the transformation matrix for the given view angles
658 VectorCopy (r_refdef.vieworg, r_origin);
660 AngleVectors (r_refdef.viewangles, vpn, vright, vup);
663 r_oldviewleaf = r_viewleaf;
664 r_viewleaf = Mod_PointInLeaf (r_origin, cl.worldmodel);
666 V_SetContentsColor (r_viewleaf->contents);
669 r_cache_thrash = false;
687 void MYgluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar )
689 GLdouble xmin, xmax, ymin, ymax;
691 ymax = zNear * tan( fovy * M_PI / 360.0 );
694 xmin = ymin * aspect;
695 xmax = ymax * aspect;
697 glFrustum( xmin, xmax, ymin, ymax, zNear, zFar );
706 void R_SetupGL (void)
709 int x, x2, y2, y, w, h;
716 glMatrixMode(GL_PROJECTION);
718 x = r_refdef.vrect.x * glwidth/vid.width;
719 x2 = (r_refdef.vrect.x + r_refdef.vrect.width) * glwidth/vid.width;
720 y = (vid.height-r_refdef.vrect.y) * glheight/vid.height;
721 y2 = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height)) * glheight/vid.height;
723 // fudge around because of frac screen scale
742 glViewport (glx + x, gly + y2, w, h);
743 screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
744 // yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI;
745 MYgluPerspective (r_refdef.fov_y, screenaspect, 4, r_farclip.value);
747 glCullFace(GL_FRONT);
749 glMatrixMode(GL_MODELVIEW);
752 glRotatef (-90, 1, 0, 0); // put Z going up
753 glRotatef (90, 0, 0, 1); // put Z going up
754 glRotatef (-r_refdef.viewangles[2], 1, 0, 0);
755 glRotatef (-r_refdef.viewangles[0], 0, 1, 0);
756 glRotatef (-r_refdef.viewangles[1], 0, 0, 1);
757 glTranslatef (-r_refdef.vieworg[0], -r_refdef.vieworg[1], -r_refdef.vieworg[2]);
759 glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
764 // if (gl_cull.value)
765 glEnable(GL_CULL_FACE);
767 // glDisable(GL_CULL_FACE);
769 glEnable(GL_BLEND); // was Disable
770 glDisable(GL_ALPHA_TEST);
771 glAlphaFunc(GL_GREATER, 0.5);
772 glEnable(GL_DEPTH_TEST);
774 glShadeModel(GL_SMOOTH);
786 // glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // LordHavoc: moved to SCR_UpdateScreen
789 glDepthFunc (GL_LEQUAL);
791 glDepthRange (gldepthmin, gldepthmax);
794 // LordHavoc: my trick to *FIX* GLQuake lighting once and for all :)
795 void GL_Brighten(void)
799 glMatrixMode(GL_PROJECTION);
801 glOrtho (0, vid.width, vid.height, 0, -99999, 99999);
802 glMatrixMode(GL_MODELVIEW);
804 glDisable (GL_DEPTH_TEST);
805 glDisable (GL_CULL_FACE);
806 glDisable(GL_TEXTURE_2D);
808 glBlendFunc (GL_DST_COLOR, GL_ONE);
809 glBegin (GL_TRIANGLES);
811 glVertex2f (-5000, -5000);
812 glVertex2f (10000, -5000);
813 glVertex2f (-5000, 10000);
815 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
817 glEnable(GL_TEXTURE_2D);
818 glEnable (GL_DEPTH_TEST);
819 glEnable (GL_CULL_FACE);
822 void GL_BlendView(void)
827 if (v_blend[3] < 0.01f)
830 glMatrixMode(GL_PROJECTION);
832 glOrtho (0, vid.width, vid.height, 0, -99999, 99999);
833 glMatrixMode(GL_MODELVIEW);
835 glDisable (GL_DEPTH_TEST);
836 glDisable (GL_CULL_FACE);
837 glDisable(GL_TEXTURE_2D);
839 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
840 glBegin (GL_TRIANGLES);
842 glColor4f (v_blend[0] * 0.5f, v_blend[1] * 0.5f, v_blend[2] * 0.5f, v_blend[3]);
844 glColor4fv (v_blend);
845 glVertex2f (-5000, -5000);
846 glVertex2f (10000, -5000);
847 glVertex2f (-5000, 10000);
850 glEnable (GL_CULL_FACE);
851 glEnable (GL_DEPTH_TEST);
853 glEnable(GL_TEXTURE_2D);
860 r_refdef must be set before the first call
863 extern void R_Sky(void);
864 extern void UploadLightmaps(void);
865 extern void R_DrawSurfaces(void);
866 extern void R_DrawPortals(void);
867 char r_speeds2_string[1024];
868 int speedstringcount;
870 void timestring(int t, char *desc)
875 sprintf(tempbuf, " %6ius %s", t, desc);
877 sprintf(tempbuf, " %6ims %s", t / 1000, desc);
878 length = strlen(tempbuf);
879 // while (length < 20)
880 // tempbuf[length++] = ' ';
881 // tempbuf[length] = 0;
882 if (speedstringcount + length > 80)
884 strcat(r_speeds2_string, "\n");
885 speedstringcount = 0;
887 // skip the space at the beginning if it's the first on the line
888 if (speedstringcount == 0)
890 strcat(r_speeds2_string, tempbuf + 1);
891 speedstringcount = length - 1;
895 strcat(r_speeds2_string, tempbuf);
896 speedstringcount += length;
900 #define TIMEREPORT(NAME) \
901 if (r_speeds2.value)\
903 temptime = currtime;\
904 currtime = Sys_DoubleTime();\
905 timestring((int) ((currtime - temptime) * 1000000.0), NAME);\
908 void R_RenderView (void)
910 double starttime, currtime, temptime;
911 // if (r_norefresh.value)
915 Host_Error ("R_RenderView: NULL worldmodel");
919 starttime = currtime = Sys_DoubleTime();
921 speedstringcount = 0;
922 sprintf(r_speeds2_string, "org:'%c%6.2f %c%6.2f %c%6.2f' ang:'%c%3.0f %c%3.0f %c%3.0f' dir:'%c%2.3f %c%2.3f %c%2.3f'\n%6i walls %6i dlitwalls %7i modeltris %7i transpoly\nBSP: %6i faces %6i nodes %6i leafs\n%4i models %4i bmodels %4i sprites %5i particles %3i dlights\n",
923 r_origin[0] < 0 ? '-' : ' ', fabs(r_origin[0]), r_origin[1] < 0 ? '-' : ' ', fabs(r_origin[1]), r_origin[2] < 0 ? '-' : ' ', fabs(r_origin[2]), r_refdef.viewangles[0] < 0 ? '-' : ' ', fabs(r_refdef.viewangles[0]), r_refdef.viewangles[1] < 0 ? '-' : ' ', fabs(r_refdef.viewangles[1]), r_refdef.viewangles[2] < 0 ? '-' : ' ', fabs(r_refdef.viewangles[2]), vpn[0] < 0 ? '-' : ' ', fabs(vpn[0]), vpn[1] < 0 ? '-' : ' ', fabs(vpn[1]), vpn[2] < 0 ? '-' : ' ', fabs(vpn[2]),
924 c_brush_polys, c_light_polys, c_alias_polys, currenttranspoly,
925 c_faces, c_nodes, c_leafs,
926 c_models, c_bmodels, c_sprites, c_particles, c_dlights);
929 starttime = currtime = 0;
934 lighthalf = gl_lightmode.value;
941 // render normal view
959 R_AddModelEntities();
960 TIMEREPORT("addmodels")
963 TIMEREPORT("scanedge ")
965 // now mark the lit surfaces
967 // yes this does add the world surfaces after the brush models
970 TIMEREPORT("surfaces ");
973 TIMEREPORT("uploadlmap")
975 // fogged sky polys, affects depth
978 // does not affect depth, draws over the sky polys
981 TIMEREPORT("skypoly ")
984 TIMEREPORT("wallpoly ")
987 TIMEREPORT("ddecal ")
989 // don't let sound skip if going slow
990 if (!intimerefresh && !r_speeds2.value)
995 TIMEREPORT("models ")
998 TIMEREPORT("dparticles")
1000 TIMEREPORT("dexplosion")
1003 TIMEREPORT("transpoly ")
1008 TIMEREPORT("blend ")
1010 if (r_speeds2.value)
1011 timestring((int) ((Sys_DoubleTime() - starttime) * 1000000.0), "total ");