/* =============== R_SetupFrame =============== */ void R_SetupFrame (void) { int edgecount; vrect_t vrect; float w, h; // don't allow cheats in multiplayer if (cl.maxclients > 1) { Cvar_Set ("r_draworder", "0"); Cvar_Set ("r_fullbright", "0"); Cvar_Set ("r_ambient", "0"); Cvar_Set ("r_drawflat", "0"); } if (r_numsurfs.value) { if ((surface_p - surfaces) > r_maxsurfsseen) r_maxsurfsseen = surface_p - surfaces; Con_Printf ("Used %d of %d surfs; %d max\n", surface_p - surfaces, surf_max - surfaces, r_maxsurfsseen); } if (r_numedges.value) { edgecount = edge_p - r_edges; if (edgecount > r_maxedgesseen) r_maxedgesseen = edgecount; Con_Printf ("Used %d of %d edges; %d max\n", edgecount, r_numallocatededges, r_maxedgesseen); } r_refdef.ambientlight = r_ambient.value; if (r_refdef.ambientlight < 0) r_refdef.ambientlight = 0; if (!sv.active) r_draworder.value = 0; // don't let cheaters look behind walls R_CheckVariables (); R_AnimateLight (); r_framecount++; numbtofpolys = 0; // debugging #if 0 r_refdef.vieworg[0]= 80; r_refdef.vieworg[1]= 64; r_refdef.vieworg[2]= 40; r_refdef.viewangles[0]= 0; r_refdef.viewangles[1]= 46.763641357; r_refdef.viewangles[2]= 0; #endif // build the transformation matrix for the given view angles VectorCopy (r_refdef.vieworg, modelorg); VectorCopy (r_refdef.vieworg, r_origin); AngleVectors (r_refdef.viewangles, vpn, vright, vup); // current viewleaf r_oldviewleaf = r_viewleaf; r_viewleaf = Mod_PointInLeaf (r_origin, cl.worldmodel); r_dowarpold = r_dowarp; r_dowarp = r_waterwarp.value && (r_viewleaf->contents <= CONTENTS_WATER); if ((r_dowarp != r_dowarpold) || r_viewchanged || lcd_x.value) { if (r_dowarp) { if ((vid.width <= vid.maxwarpwidth) && (vid.height <= vid.maxwarpheight)) { vrect.x = 0; vrect.y = 0; vrect.width = vid.width; vrect.height = vid.height; R_ViewChanged (&vrect, sb_lines, vid.aspect); } else { w = vid.width; h = vid.height; if (w > vid.maxwarpwidth) { h *= (float)vid.maxwarpwidth / w; w = vid.maxwarpwidth; } if (h > vid.maxwarpheight) { h = vid.maxwarpheight; w *= (float)vid.maxwarpheight / h; } vrect.x = 0; vrect.y = 0; vrect.width = (int)w; vrect.height = (int)h; R_ViewChanged (&vrect, (int)((float)sb_lines * (h/(float)vid.height)), vid.aspect * (h / w) * ((float)vid.width / (float)vid.height)); } } else { vrect.x = 0; vrect.y = 0; vrect.width = vid.width; vrect.height = vid.height; R_ViewChanged (&vrect, sb_lines, vid.aspect); } r_viewchanged = false; } // start off with just the four screen edge clip planes R_TransformFrustum (); // save base values VectorCopy (vpn, base_vpn); VectorCopy (vright, base_vright); VectorCopy (vup, base_vup); VectorCopy (modelorg, base_modelorg); R_SetSkyFrame (); R_SetUpFrustumIndexes (); r_cache_thrash = false; // clear frame counts c_faceclip = 0; d_spanpixcount = 0; r_polycount = 0; r_drawnpolycount = 0; r_wholepolycount = 0; r_amodels_drawn = 0; r_outofsurfaces = 0; r_outofedges = 0; D_SetupFrame (); }
void R_SetupFrame (void) { int edgecount; vrect_t vrect; float w, h; int dtail = 2; // leilei - screen detail // don't allow cheats in multiplayer if (cl.maxclients > 1) { Cvar_Set (r_draworder, "0"); Cvar_Set (r_fullbright, "0"); Cvar_Set (r_ambient, "0"); Cvar_Set (r_drawflat, "0"); } if (r_numsurfs->value) { if ((surface_p - surfaces) > r_maxsurfsseen) r_maxsurfsseen = surface_p - surfaces; Con_Printf ("Used %d of %d surfs; %d max\n", surface_p - surfaces, surf_max - surfaces, r_maxsurfsseen); } if (r_numedges->value) { edgecount = edge_p - r_edges; if (edgecount > r_maxedgesseen) r_maxedgesseen = edgecount; Con_Printf ("Used %d of %d edges; %d max\n", edgecount, r_numallocatededges, r_maxedgesseen); } r_refdef.ambientlight = r_ambient->value; if (r_refdef.ambientlight < 0) r_refdef.ambientlight = 0; if (!sv.active) r_draworder->value = 0; // don't let cheaters look behind walls R_CheckVariables (); R_AnimateLight (); r_framecount++; numbtofpolys = 0; VectorCopy (r_refdef.vieworg, modelorg); VectorCopy (r_refdef.vieworg, r_origin); AngleVectors (r_refdef.viewangles, vpn, vright, vup); // current viewleaf r_oldviewleaf = r_viewleaf; r_viewleaf = Mod_PointInLeaf (r_origin, cl.worldmodel); scalefactoid = vid.height / vid.vconheight; // leilei r_dowarpold = r_dowarp; r_dowarp = r_waterwarp->value && (r_viewleaf->contents <= CONTENTS_WATER); inwat = s_underwater->value && (r_viewleaf->contents <= CONTENTS_WATER); if ((r_dowarp != r_dowarpold) || r_viewchanged || r_virtualmode->value || lcd_x->value || v_detail->value) { if (r_docrap == 1) { if ((vid.width <= vid.maxlowwidth) && (vid.height <= vid.maxlowheight)) { vrect.x = 0; vrect.y = 0; vrect.width = vid.width; vrect.height = vid.height; R_SetVrect (&vrect, &r_refdef.vrect, 0); R_ViewChanged (&vrect, 0, vid.aspect); } else { w = vid.width; h = vid.height; if (w > vid.maxlowwidth) { h *= (float)vid.maxlowwidth / w; w = vid.maxlowwidth; } if (h > vid.maxlowheight) { h = vid.maxlowheight; w *= (float)vid.maxlowheight / h; } vrect.x = 0; vrect.y = 0; vrect.width = (int)w; vrect.height = (int)h; R_SetVrect (&vrect, &r_refdef.vrect, ((float)vid.height)); R_ViewChanged (&vrect, 0, vid.aspect * (h / w) * ((float)vid.width / (float)vid.height)); } } else if(r_docrap > 1) { if ((vid.width <= vid.maxwarpwidth) && (vid.height <= vid.maxwarpheight)) { vrect.x = 0; vrect.y = 0; vrect.width = vid.width; vrect.height = vid.height; R_SetVrect (&vrect, &r_refdef.vrect, ((float)vid.height)); R_ViewChanged (&vrect, 0, vid.aspect); } else { w = vid.width; h = vid.height; if (w > vid.maxwarpwidth) { h *= (float)vid.maxwarpwidth / w; w = vid.maxwarpwidth; } if (h > vid.maxwarpheight) { h = vid.maxwarpheight; w *= (float)vid.maxwarpheight / h; } vrect.x = 0; vrect.y = 0; vrect.width = (int)w; vrect.height = (int)h; R_SetVrect (&vrect, &r_refdef.vrect, (h/(float)vid.height)); R_ViewChanged (&vrect, (h/(float)vid.height), vid.aspect * (h / w) * ((float)vid.width / (float)vid.height)); } } else { vrect.x = 0; vrect.y = 0; vrect.width = vid.width; vrect.height = vid.height; R_ViewChanged (&vrect, 0, vid.aspect); } r_viewchanged = false; } // start off with just the four screen edge clip planes R_TransformFrustum (); // save base values VectorCopy (vpn, base_vpn); VectorCopy (vright, base_vright); VectorCopy (vup, base_vup); VectorCopy (modelorg, base_modelorg); R_SetSkyFrame (); // Only do the sky moving on Quack R_SetUpFrustumIndexes (); r_cache_thrash = false; // clear frame counts c_faceclip = 0; d_spanpixcount = 0; r_polycount = 0; r_drawnpolycount = 0; r_wholepolycount = 0; r_amodels_drawn = 0; r_outofsurfaces = 0; r_outofedges = 0; // WarpPalette(); #ifdef EXPREND D_SetupFrameExperimental (); #else D_SetupFrame (); #endif }