1
0
Fork 0
forked from fte/fteqw

try and do something smarter with x11 and refresh rates.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4762 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2014-10-07 13:50:58 +00:00
parent 2a58bd0d74
commit 9ff0f6ff6e

View file

@ -1567,6 +1567,7 @@ qboolean X11VID_Init (rendererstate_t *info, unsigned char *palette, int psl)
{ {
int width = info->width; //can override these if vmode isn't available int width = info->width; //can override these if vmode isn't available
int height = info->height; int height = info->height;
int rate = info->rate;
int i; int i;
int attrib[] = { int attrib[] = {
GLX_RGBA, GLX_RGBA,
@ -1630,9 +1631,9 @@ qboolean X11VID_Init (rendererstate_t *info, unsigned char *palette, int psl)
fullscreenflags = 0; fullscreenflags = 0;
vm.usemode = -1; vm.usemode = -1;
if (vm.vmajor) if (vm.vmajor && !COM_CheckParm("-current"))
{ {
int best_fit, best_dist, dist, x, y; int best_fit, best_dist, dist, x, y, z, r;
vm.pXF86VidModeGetAllModeLines(vid_dpy, scrnum, &vm.num_modes, &vm.modes); vm.pXF86VidModeGetAllModeLines(vid_dpy, scrnum, &vm.num_modes, &vm.modes);
// Are we going fullscreen? If so, let's change video mode // Are we going fullscreen? If so, let's change video mode
@ -1643,13 +1644,17 @@ qboolean X11VID_Init (rendererstate_t *info, unsigned char *palette, int psl)
for (i = 0; i < vm.num_modes; i++) for (i = 0; i < vm.num_modes; i++)
{ {
//fixme: check this formula. should be the full refresh rate
r = vm.modes[i]->dotclock * 1000 / (vm.modes[i]->htotal * vm.modes[i]->vtotal);
if (width > vm.modes[i]->hdisplay || if (width > vm.modes[i]->hdisplay ||
height > vm.modes[i]->vdisplay) height > vm.modes[i]->vdisplay ||
rate > r)
continue; continue;
x = width - vm.modes[i]->hdisplay; x = width - vm.modes[i]->hdisplay;
y = height - vm.modes[i]->vdisplay; y = height - vm.modes[i]->vdisplay;
dist = (x * x) + (y * y); z = rate - r;
dist = (x * x) + (y * y) + (z * z);
if (dist < best_dist) if (dist < best_dist)
{ {
best_dist = dist; best_dist = dist;