added vid_minwidth/vid_minheight for use by menu, this lets a mod specify minimum acceptable resolution
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5854
d7cf8633-e32d-0410-b094-
e92efae38249
int height;
int bitsperpixel;
int fullscreen;
int height;
int bitsperpixel;
int fullscreen;
} viddef_t;
// global video state
} viddef_t;
// global video state
extern qboolean vid_activewindow;
extern cvar_t vid_hardwaregammasupported;
extern qboolean vid_usinghwgamma;
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_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_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;
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
// 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)
// allocates and opens an appropriate OpenGL context (and its window)
// Tell startup code that we have a client
int cl_available = true;
// Tell startup code that we have a client
int cl_available = true;
+qboolean vid_supportrefreshrate = false;
+
// AGL prototypes
AGLPixelFormat (*qaglChoosePixelFormat) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList);
AGLContext (*qaglCreateContext) (AGLPixelFormat pix, AGLContext share);
// AGL prototypes
AGLPixelFormat (*qaglChoosePixelFormat) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList);
AGLContext (*qaglCreateContext) (AGLPixelFormat pix, AGLContext share);
-int VID_InitMode(int fullscreen, int width, int height, int bpp)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
{
const EventTypeSpec winEvents[] =
{
{
const EventTypeSpec winEvents[] =
{
// Tell startup code that we have a client
int cl_available = true;
// Tell startup code that we have a client
int cl_available = true;
+// note: if we used the XRandR extension we could support refresh rates
+qboolean vid_supportrefreshrate = false;
+
//GLX prototypes
XVisualInfo *(GLAPIENTRY *qglXChooseVisual)(Display *dpy, int screen, int *attribList);
GLXContext (GLAPIENTRY *qglXCreateContext)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
//GLX prototypes
XVisualInfo *(GLAPIENTRY *qglXChooseVisual)(Display *dpy, int screen, int *attribList);
GLXContext (GLAPIENTRY *qglXCreateContext)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
-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 cl_available = false;
int cl_available = false;
+qboolean vid_supportrefreshrate = false;
+
void VID_Shutdown(void)
{
}
void VID_Shutdown(void)
{
}
InitSig(); // trap evil signals
}
InitSig(); // trap evil signals
}
-int VID_InitMode(int fullscreen, int width, int height, int bpp)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
// Tell startup code that we have a client
int cl_available = true;
// Tell startup code that we have a client
int cl_available = true;
+
+qboolean vid_supportrefreshrate = false;
+
static qboolean vid_usingmouse;
static qboolean vid_isfullscreen;
static qboolean vid_usingmouse;
static qboolean vid_isfullscreen;
version->major, version->minor, version->patch );
}
version->major, version->minor, version->patch );
}
-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;
int flags = SDL_OPENGL;
{
int i;
int flags = SDL_OPENGL;
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_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_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_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_width);
Cvar_RegisterVariable(&vid_height);
Cvar_RegisterVariable(&vid_bitsperpixel);
+ Cvar_RegisterVariable(&vid_refreshrate);
Cvar_RegisterVariable(&vid_vsync);
Cvar_RegisterVariable(&vid_mouse);
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_RegisterVariable(&gl_combine);
Cvar_RegisterVariable(&gl_finish);
Cmd_AddCommand("force_centerview", Force_CenterView_f);
Cvar_Set("gl_combine", "0");
}
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.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_fullscreen, fullscreen);
Cvar_SetValueQuick(&vid_width, width);
Cvar_SetValueQuick(&vid_height, height);
Cvar_SetValueQuick(&vid_bitsperpixel, bpp);
+ Cvar_SetValueQuick(&vid_refreshrate, refreshrate);
vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
VID_CloseSystems();
VID_Shutdown();
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");
{
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();
Sys_Error("Unable to restore to last working video mode");
}
VID_OpenSystems();
}
Con_Print("Starting video system\n");
}
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");
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)
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))
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)
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");
}
if (!success)
Sys_Error("Video modes failed");
}
// Tell startup code that we have a client
int cl_available = true;
// 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);
static int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
static int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
//static int (WINAPI *qwglGetPixelFormat)(HDC);
-int VID_InitMode (int fullscreen, int width, int height, int bpp)
+int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate)
vid_isfullscreen = false;
if (fullscreen)
{
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.dmBitsPerPel = bpp;
gdevmode.dmPelsWidth = width;
gdevmode.dmPelsHeight = height;
+ gdevmode.dmDisplayFrequency = refreshrate;
gdevmode.dmSize = sizeof (gdevmode);
if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
gdevmode.dmSize = sizeof (gdevmode);
if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{