gl_screen.c: some fov_adapt style syncing with uhexen2

git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@838 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
svdijk 2013-03-02 18:52:22 +00:00
parent b94d90a17a
commit e82eb5b316

View file

@ -231,26 +231,24 @@ void SCR_CheckDrawCenterString (void)
/* /*
==================== ====================
AdaptFovx AdaptFovx
Adapt a 4:3 horizontal FOV to the current screen size using the "Hor+" scaling:
Adapts a 4:3 horizontal FOV to the current screen size (Hor+). 2.0 * atan(width / height * 3.0 / 4.0 * tan(fov_x / 2.0))
==================== ====================
*/ */
float AdaptFovx (float fov43, float w, float h) float AdaptFovx (float fov_x, float width, float height)
{ {
static const float pi = M_PI; /* float instead of double. */ float a, x;
if (w <= 0 || h <= 0) if (fov_x < 1 || fov_x > 179)
return fov43; Sys_Error ("Bad fov: %f", fov_x);
/* if (!scr_fov_adapt.value)
* Formula: return fov_x;
* if ((x = height / width) == 0.75)
* fov = 2.0 * atan(width / height * 3.0 / 4.0 * tan(fov43 / 2.0)) return fov_x;
* a = atan(0.75 / x * tan(fov_x / 360 * M_PI));
* The code below is equivalent but precalculates a few values and a = a * 360 / M_PI;
* converts between degrees and radians when needed. return a;
*/
return (atanf(tanf(fov43 / 360.0f * pi) * (w / h) * 0.75f) / pi * 360.0f);
} }
/* /*
@ -323,11 +321,7 @@ static void SCR_CalcRefdef (void)
r_refdef.vrect.y = (glheight - sb_lines - r_refdef.vrect.height)/2; r_refdef.vrect.y = (glheight - sb_lines - r_refdef.vrect.height)/2;
//johnfitz //johnfitz
if (scr_fov_adapt.value)
r_refdef.fov_x = AdaptFovx(scr_fov.value, r_refdef.vrect.width, r_refdef.vrect.height); r_refdef.fov_x = AdaptFovx(scr_fov.value, r_refdef.vrect.width, r_refdef.vrect.height);
else
r_refdef.fov_x = scr_fov.value;
r_refdef.fov_x = CLAMP (10, r_refdef.fov_x, 170);
r_refdef.fov_y = CalcFovy (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height); r_refdef.fov_y = CalcFovy (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);
scr_vrect = r_refdef.vrect; scr_vrect = r_refdef.vrect;