コード例 #1
0
ファイル: screen.c プロジェクト: AidHamza/eviltoys
/*
=================
SCR_CalcRefdef

Must be called whenever vid changes
Internal use only
=================
*/
static void
SCR_CalcRefdef(void)
{
    vrect_t vrect;
    float size;

    scr_fullupdate = 0;		// force a background redraw
    vid.recalc_refdef = 0;

// force the status bar to redraw
    Sbar_Changed();

//========================================

// bound viewsize
    if (scr_viewsize.value < 30)
        Cvar_Set("viewsize", "30");
    if (scr_viewsize.value > 120)
        Cvar_Set("viewsize", "120");

// bound field of view
    if (scr_fov.value < 10)
        Cvar_Set("fov", "10");
    if (scr_fov.value > 170)
        Cvar_Set("fov", "170");

    r_refdef.fov_x = scr_fov.value;
    r_refdef.fov_y =
        CalcFov(r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);

// intermission is always full screen
    if (cl.intermission)
        size = 120;
    else
        size = scr_viewsize.value;

    if (size >= 120)
        sb_lines = 0;		// no status bar at all
    else if (size >= 110)
        sb_lines = 24;		// no inventory
    else
        sb_lines = 24 + 16 + 8;

// these calculations mirror those in R_Init() for r_refdef, but take no
// account of water warping
    vrect.x = 0;
    vrect.y = 0;
    vrect.width = vid.width;
    vrect.height = vid.height;

    R_SetVrect(&vrect, &scr_vrect, sb_lines);

// guard against going from one mode to another that's less than half the
// vertical resolution
    if (scr_con_current > vid.height)
        scr_con_current = vid.height;

// notify the refresh of the change
    R_ViewChanged(&vrect, sb_lines, vid.aspect);
}
コード例 #2
0
ファイル: r_misc.c プロジェクト: eukos16/NGUNIX
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
}
コード例 #3
0
ファイル: screen.c プロジェクト: luaman/qforge-newtree
/*
	SCR_CalcRefdef

	Must be called whenever vid changes
	Internal use only
*/
static void
SCR_CalcRefdef (void)
{
	vrect_t     vrect;
	float       size;
	int         h;
	qboolean    full = false;

	scr_fullupdate = 0;					// force a background redraw
	vid.recalc_refdef = 0;

	// force the status bar to redraw
	Sbar_Changed ();

//========================================

	// bound viewsize
	Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120));

	// bound field of view
	Cvar_SetValue (scr_fov, bound (10, scr_fov->value, 170));

	if (scr_viewsize->int_val >= 120)
		sb_lines = 0;					// no status bar at all
	else if (scr_viewsize->int_val >= 110)
		sb_lines = 24;					// no inventory
	else
		sb_lines = 24 + 16 + 8;

	if (scr_viewsize->int_val >= 100) {
		full = true;
		size = 100.0;
	} else {
		size = scr_viewsize->int_val;
	}
	// intermission is always full screen
	if (cl.intermission) {
		full = true;
		size = 100.0;
		sb_lines = 0;
	}
	size /= 100.0;

	if (!cl_sbar->int_val && full)
		h = vid.height;
	else
		h = vid.height - sb_lines;

	r_refdef.vrect.width = vid.width * size + 0.5;
	if (r_refdef.vrect.width < 96) {
		size = 96.0 / r_refdef.vrect.width;
		r_refdef.vrect.width = 96;		// min for icons
	}

	r_refdef.vrect.height = vid.height * size + 0.5;
	if (cl_sbar->int_val || !full) {
		if (r_refdef.vrect.height > vid.height - sb_lines)
			r_refdef.vrect.height = vid.height - sb_lines;
	} else if (r_refdef.vrect.height > vid.height)
		r_refdef.vrect.height = vid.height;
	r_refdef.vrect.x = (vid.width - r_refdef.vrect.width) / 2;
	if (full)
		r_refdef.vrect.y = 0;
	else
		r_refdef.vrect.y = (h - r_refdef.vrect.height) / 2;

	r_refdef.fov_x = scr_fov->int_val;
	r_refdef.fov_y =
		CalcFov (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);

	scr_vrect = r_refdef.vrect;

	// these calculations mirror those in R_Init() for r_refdef, but take no
	// account of water warping
	vrect.x = 0;
	vrect.y = 0;
	vrect.width = vid.width;
	vrect.height = vid.height;

	R_SetVrect (&vrect, &scr_vrect, sb_lines);

	// guard against going from one mode to another that's less than half the
	// vertical resolution
	if (scr_con_current > vid.height)
		scr_con_current = vid.height;

	// notify the refresh of the change
	R_ViewChanged (&vrect, sb_lines, vid.aspect);
}