int height;
int bitsperpixel;
int fullscreen;
+ int refreshrate;
} viddef_t;
// global video state
extern qboolean vid_activewindow;
extern cvar_t vid_hardwaregammasupported;
extern qboolean vid_usinghwgamma;
+extern qboolean vid_supportrefreshrate;
extern cvar_t vid_fullscreen;
extern cvar_t vid_width;
extern cvar_t vid_height;
extern cvar_t vid_bitsperpixel;
+extern cvar_t vid_refreshrate;
extern cvar_t vid_vsync;
extern cvar_t vid_mouse;
+extern cvar_t vid_minwidth;
+extern cvar_t vid_minheight;
extern cvar_t gl_combine;
extern cvar_t gl_finish;
// sets the mode; only used by the Quake engine for resetting to mode 0 (the
// base mode) on memory allocation failures
-int VID_InitMode(int fullscreen, int width, int height, int bpp);
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate);
// allocates and opens an appropriate OpenGL context (and its window)
cvar_t vid_width = {CVAR_SAVE, "vid_width", "640"};
cvar_t vid_height = {CVAR_SAVE, "vid_height", "480"};
cvar_t vid_bitsperpixel = {CVAR_SAVE, "vid_bitsperpixel", "32"};
+cvar_t vid_refreshrate = {CVAR_SAVE, "vid_refreshrate", "60"};
cvar_t vid_vsync = {CVAR_SAVE, "vid_vsync", "0"};
cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
+cvar_t vid_minwidth = {0, "vid_minwidth", "0"};
+cvar_t vid_minheight = {0, "vid_minheight", "0"};
cvar_t gl_combine = {0, "gl_combine", "1"};
cvar_t gl_finish = {0, "gl_finish", "0"};
Cvar_RegisterVariable(&vid_width);
Cvar_RegisterVariable(&vid_height);
Cvar_RegisterVariable(&vid_bitsperpixel);
+ Cvar_RegisterVariable(&vid_refreshrate);
Cvar_RegisterVariable(&vid_vsync);
Cvar_RegisterVariable(&vid_mouse);
+ Cvar_RegisterVariable(&vid_minwidth);
+ Cvar_RegisterVariable(&vid_minheight);
Cvar_RegisterVariable(&gl_combine);
Cvar_RegisterVariable(&gl_finish);
Cmd_AddCommand("force_centerview", Force_CenterView_f);
Cvar_Set("gl_combine", "0");
}
-int VID_Mode(int fullscreen, int width, int height, int bpp)
+int VID_Mode(int fullscreen, int width, int height, int bpp, int refreshrate)
{
- Con_Printf("Video: %s %dx%dx%d\n", fullscreen ? "fullscreen" : "window", width, height, bpp);
- if (VID_InitMode(fullscreen, width, height, bpp))
+ Con_Printf("Video: %s %dx%dx%dx%dhz\n", fullscreen ? "fullscreen" : "window", width, height, bpp, refreshrate);
+ if (VID_InitMode(fullscreen, width, height, bpp, refreshrate))
{
vid.fullscreen = fullscreen;
vid.width = width;
vid.height = height;
vid.bitsperpixel = bpp;
+ vid.refreshrate = refreshrate;
Cvar_SetValueQuick(&vid_fullscreen, fullscreen);
Cvar_SetValueQuick(&vid_width, width);
Cvar_SetValueQuick(&vid_height, height);
Cvar_SetValueQuick(&vid_bitsperpixel, bpp);
+ Cvar_SetValueQuick(&vid_refreshrate, refreshrate);
return true;
}
else
vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
VID_CloseSystems();
VID_Shutdown();
- if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
+ if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer))
{
Con_Print("Video mode change failed\n");
- if (!VID_Mode(vid.fullscreen, vid.width, vid.height, vid.bitsperpixel))
+ if (!VID_Mode(vid.fullscreen, vid.width, vid.height, vid.bitsperpixel, vid.refreshrate))
Sys_Error("Unable to restore to last working video mode");
}
VID_OpenSystems();
}
Con_Print("Starting video system\n");
- success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
+ success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer);
if (!success)
{
Con_Print("Desired video mode fail, trying fallbacks...\n");
+ success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, 60);
if (!success && vid_bitsperpixel.integer > 16)
- success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, 16);
+ success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, 16, 60);
if (!success && (vid_width.integer > 640 || vid_height.integer > 480))
- success = VID_Mode(vid_fullscreen.integer, 640, 480, 16);
+ success = VID_Mode(vid_fullscreen.integer, 640, 480, 16, 60);
if (!success && vid_fullscreen.integer)
- success = VID_Mode(false, 640, 480, 16);
+ success = VID_Mode(false, 640, 480, 16, 60);
if (!success)
Sys_Error("Video modes failed");
}
// Tell startup code that we have a client
int cl_available = true;
+qboolean vid_supportrefreshrate = true;
+
static int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
static int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
//static int (WINAPI *qwglGetPixelFormat)(HDC);
IN_Init();
}
-int VID_InitMode (int fullscreen, int width, int height, int bpp)
+int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate)
{
int i;
HDC hdc;
vid_isfullscreen = false;
if (fullscreen)
{
- gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
+ gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
gdevmode.dmBitsPerPel = bpp;
gdevmode.dmPelsWidth = width;
gdevmode.dmPelsHeight = height;
+ gdevmode.dmDisplayFrequency = refreshrate;
gdevmode.dmSize = sizeof (gdevmode);
if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{