]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented vid_refreshrate cvar to specify display refresh rate in windows
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 30 Nov 2005 15:03:08 +0000 (15:03 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 30 Nov 2005 15:03:08 +0000 (15:03 +0000)
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

vid.h
vid_agl.c
vid_glx.c
vid_null.c
vid_sdl.c
vid_shared.c
vid_wgl.c

diff --git a/vid.h b/vid.h
index 34cd729e906ec14237a0d6cfdde70d1de11a2ba5..6943a8541f8456b0a687fd2b9ab3f07f5f7838ff 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -31,6 +31,7 @@ typedef struct viddef_s
        int height;
        int bitsperpixel;
        int fullscreen;
        int height;
        int bitsperpixel;
        int fullscreen;
+       int refreshrate;
 } viddef_t;
 
 // global video state
 } viddef_t;
 
 // global video state
@@ -42,13 +43,17 @@ extern qboolean vid_hidden;
 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;
@@ -117,7 +122,7 @@ int VID_SetMode (int modenum);
 // 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)
 
 
index cbca607a92e575f08592a58333fc23aaede9ab37..83de5e8df36c0ee8ef0a1c5e59d4b484f84e822f 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -31,6 +31,8 @@
 // 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);
@@ -299,7 +301,7 @@ static void VID_BuildAGLAttrib(GLint *attrib, int stencil, qboolean fullscreen)
        *attrib++ = AGL_NONE;
 }
 
        *attrib++ = AGL_NONE;
 }
 
-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[] =
        {
index cc503fda5e474a92d26b2b52e18a40d0c5fac42e..8f477f3e5151e60fdc2882924858869d461bbed0 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -45,6 +45,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // 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);
@@ -625,7 +628,7 @@ void VID_BuildGLXAttrib(int *attrib, int stencil)
        *attrib++ = None;
 }
 
        *attrib++ = None;
 }
 
-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 attrib[32];
 {
        int i;
        int attrib[32];
index 2ce3321c7bbc916be3f19a3d7c849e8da5937f81..41be51fab82ee2bf756314c48cfdd21ca4493321 100644 (file)
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 int cl_available = false;
 
 
 int cl_available = false;
 
+qboolean vid_supportrefreshrate = false;
+
 void VID_Shutdown(void)
 {
 }
 void VID_Shutdown(void)
 {
 }
@@ -68,7 +70,7 @@ void VID_Init(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)
 {
        return false;
 }
 {
        return false;
 }
index 2580104f1b6e16f385bb37d3b550606c2d71fe76..e5c844e5362718c3aeb0ae943bc47e05716a77cb 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 // 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;
 
@@ -360,7 +363,7 @@ static void VID_OutputVersion()
                                        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;
index 75c7c2cc8e381c6d7c8576516e997ac5a0a78fe3..b5cee08104107ba23c405a4a81222e1b7662922f 100644 (file)
@@ -73,9 +73,12 @@ cvar_t vid_fullscreen = {CVAR_SAVE, "vid_fullscreen", "1"};
 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"};
 
@@ -893,8 +896,11 @@ void VID_Shared_Init(void)
        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);
@@ -903,19 +909,21 @@ void VID_Shared_Init(void)
                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);
                return true;
        }
        else
                return true;
        }
        else
@@ -947,10 +955,10 @@ void VID_Restart_f(void)
                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();
@@ -992,16 +1000,17 @@ void VID_Start(void)
        }
 
        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");
        }
index 8c1180084e5fe19ddcb4624e63459b50b8473bbe..8cce143a75cf04f63b6b0f1f81ae8f2df3ceb8bf 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -40,6 +40,8 @@ extern HINSTANCE global_hInstance;
 // 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);
@@ -723,7 +725,7 @@ void VID_Init(void)
        IN_Init();
 }
 
        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;
 {
        int i;
        HDC hdc;
@@ -787,10 +789,11 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
        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)
                {