[gl] Correct calculation of screen aspect

vrect_t's fields are ints, and it was vid.aspect that prevented the
quotient being truncated. Fixes the rather squashed looking world.
This commit is contained in:
Bill Currie 2021-07-15 21:23:06 +09:00
parent 6b38a17cf1
commit 3c93d555e3
2 changed files with 8 additions and 8 deletions

View File

@ -366,7 +366,7 @@ static void
MYgluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear,
GLdouble zFar)
{
GLdouble xmin, xmax, ymin, ymax;
GLdouble xmin, xmax, ymin, ymax;
ymax = zNear * tan (fovy * M_PI / 360.0);
ymin = -ymax;
@ -400,7 +400,7 @@ R_SetupGL_Viewport_and_Perspective (void)
}
// printf ("glViewport(%d, %d, %d, %d)\n", glx + x, gly + y2, w, h);
qfglViewport (x, y2, w, h);
screenaspect = r_refdef.vrect.width / r_refdef.vrect.height;
screenaspect = r_refdef.vrect.width / (float) r_refdef.vrect.height;
MYgluPerspective (r_refdef.fov_y, screenaspect, r_nearclip->value,
r_farclip->value);
}

View File

@ -165,16 +165,10 @@ SCR_CalcRefdef (void)
vrect_t vrect;
refdef_t *refdef = r_data->refdef;
refdef->fov_y = CalcFov (refdef->fov_x, refdef->vrect.width,
refdef->vrect.height);
// force a background redraw
r_data->scr_fullupdate = 0;
r_data->vid->recalc_refdef = 0;
// bound field of view
Cvar_SetValue (scr_fov, bound (1, scr_fov->value, 170));
vrect.x = 0;
vrect.y = 0;
vrect.width = r_data->vid->width;
@ -185,6 +179,12 @@ SCR_CalcRefdef (void)
view_setgeometry (r_data->scr_view, refdef->vrect.x, refdef->vrect.y,
refdef->vrect.width, refdef->vrect.height);
// bound field of view
Cvar_SetValue (scr_fov, bound (1, scr_fov->value, 170));
refdef->fov_y = CalcFov (refdef->fov_x, refdef->vrect.width,
refdef->vrect.height);
// notify the refresh of the change
r_funcs->R_ViewChanged ();
}