mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
Proper widescreen support. The GL renderer now respects the pixel aspect calculated by the vid init code. Also, a new cvar: vid_aspect. The format is width:height and the values may be any float greater than 0. The default is 4:3, but any units may be used.
This commit is contained in:
parent
58c167eaed
commit
a5f0fbc821
2 changed files with 29 additions and 2 deletions
|
@ -462,7 +462,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 = (float) r_refdef.vrect.width / r_refdef.vrect.height;
|
||||
screenaspect = r_refdef.vrect.width * vid.aspect / r_refdef.vrect.height;
|
||||
MYgluPerspective (r_refdef.fov_y, screenaspect, r_nearclip->value,
|
||||
r_farclip->value);
|
||||
}
|
||||
|
|
|
@ -61,9 +61,30 @@ VISIBLE unsigned int d_8to24table[256];
|
|||
/* Screen size */
|
||||
cvar_t *vid_width;
|
||||
cvar_t *vid_height;
|
||||
cvar_t *vid_aspect;
|
||||
|
||||
cvar_t *vid_fullscreen;
|
||||
|
||||
static void
|
||||
vid_aspect_f (cvar_t *var)
|
||||
{
|
||||
const char *p = strchr (var->string, ':');
|
||||
float w, h;
|
||||
|
||||
if (p) {
|
||||
w = atof (var->string);
|
||||
h = atof (p + 1);
|
||||
if (w > 0.0 && h > 0.0) {
|
||||
var->vec[0] = w;
|
||||
var->vec[1] = h;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Sys_Printf ("badly formed aspect ratio: %s. Using default 4:3\n",
|
||||
var->string);
|
||||
var->vec[0] = 4.0;
|
||||
var->vec[1] = 3.0;
|
||||
}
|
||||
|
||||
void
|
||||
VID_GetWindowSize (int def_w, int def_h)
|
||||
|
@ -74,6 +95,11 @@ VID_GetWindowSize (int def_w, int def_h)
|
|||
"screen width");
|
||||
vid_height = Cvar_Get ("vid_height", va ("%d", def_h), CVAR_NONE, NULL,
|
||||
"screen height");
|
||||
vid_aspect = Cvar_Get ("vid_aspect", "4:3", CVAR_ROM, vid_aspect_f,
|
||||
"Physical screen aspect ratio in \"width:height\" format. "
|
||||
"Common values are 4:3, 5:3, 8:5, 16:9, but any width:height "
|
||||
"measurement will do (eg, 475:296.875 the approximate dimentions "
|
||||
"in mm of the display area of a certain monitor)");
|
||||
|
||||
if ((pnum = COM_CheckParm ("-width"))) {
|
||||
if (pnum >= com_argc - 1)
|
||||
|
@ -112,7 +138,8 @@ VID_GetWindowSize (int def_w, int def_h)
|
|||
vid.width = vid_width->int_val;
|
||||
vid.height = vid_height->int_val;
|
||||
|
||||
vid.aspect = (4.0 * vid.height) / (3.0 * vid.width);
|
||||
vid.aspect = ((vid_aspect->vec[0] * vid.height)
|
||||
/ (vid_aspect->vec[1] * vid.width));
|
||||
|
||||
con_width = Cvar_Get ("con_width", va ("%d", vid.width), CVAR_NONE, NULL,
|
||||
"console effective width (GL only)");
|
||||
|
|
Loading…
Reference in a new issue