]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed VID_InitMode to take a viddef_mode_t structure which contains
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 7 Dec 2009 15:50:45 +0000 (15:50 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 7 Dec 2009 15:50:45 +0000 (15:50 +0000)
the desired parameters, and allows it to modify them (previously only
width/height could be modified)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9552 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 ba6d060a697aab76af941b6edc256e9a018ae0be..1b991403484e81281d2789a8d2ff0da8f0024ebb 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -26,9 +26,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 extern int cl_available;
 
 
 extern int cl_available;
 
+typedef struct viddef_mode_s
+{
+       int width;
+       int height;
+       int bitsperpixel;
+       qboolean fullscreen;
+       float refreshrate;
+       qboolean userefreshrate;
+       qboolean stereobuffer;
+       int samples;
+}
+viddef_mode_t;
+
 typedef struct viddef_s
 {
        // these are set by VID_Mode
 typedef struct viddef_s
 {
        // these are set by VID_Mode
+       viddef_mode_t mode;
        int width;
        int height;
        int bitsperpixel;
        int width;
        int height;
        int bitsperpixel;
@@ -127,7 +141,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 refreshrate, int stereobuffer, int samples);
+qboolean VID_InitMode(viddef_mode_t *mode);
 // allocates and opens an appropriate OpenGL context (and its window)
 
 
 // allocates and opens an appropriate OpenGL context (and its window)
 
 
index c5c55fa2b710ffc72d34e009abe5a0acedbf1908..af5c8b7f9d005c333d00dbce3abde1b37d414690 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -68,8 +68,6 @@ static qboolean vid_usingvsync = false;
 
 static qboolean sound_active = true;
 
 
 static qboolean sound_active = true;
 
-static int scr_width, scr_height;
-
 static cvar_t apple_multithreadedgl = {CVAR_SAVE, "apple_multithreadedgl", "1", "makes use of a second thread for the OpenGL driver (if possible) rather than using the engine thread (note: this is done automatically on most other operating systems)"};
 static cvar_t apple_mouse_noaccel = {CVAR_SAVE, "apple_mouse_noaccel", "1", "disables mouse acceleration while DarkPlaces is active"};
 
 static cvar_t apple_multithreadedgl = {CVAR_SAVE, "apple_multithreadedgl", "1", "makes use of a second thread for the OpenGL driver (if possible) rather than using the engine thread (note: this is done automatically on most other operating systems)"};
 static cvar_t apple_mouse_noaccel = {CVAR_SAVE, "apple_mouse_noaccel", "1", "disables mouse acceleration while DarkPlaces is active"};
 
@@ -99,13 +97,6 @@ io_connect_t IN_GetIOHandle(void)
        return iohandle;
 }
 
        return iohandle;
 }
 
-void VID_GetWindowSize (int *x, int *y, int *width, int *height)
-{
-       *x = *y = 0;
-       *width = scr_width;
-       *height = scr_height;
-}
-
 void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
 {
        if (!mouse_avail || !window)
 void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
 {
        if (!mouse_avail || !window)
@@ -539,9 +530,9 @@ static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscr
        *attrib++ = AGL_NONE;
 }
 
        *attrib++ = AGL_NONE;
 }
 
-int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
+qboolean VID_InitMode(viddef_mode_t *mode)
 {
 {
-    const EventTypeSpec winEvents[] =
+       const EventTypeSpec winEvents[] =
        {
                { kEventClassWindow, kEventWindowClosed },
                { kEventClassWindow, kEventWindowCollapsing },
        {
                { kEventClassWindow, kEventWindowClosed },
                { kEventClassWindow, kEventWindowCollapsing },
@@ -591,8 +582,8 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
        // Create the window, a bit towards the center of the screen
        windowBounds.left = 100;
        windowBounds.top = 100;
        // Create the window, a bit towards the center of the screen
        windowBounds.left = 100;
        windowBounds.top = 100;
-       windowBounds.right = *width + 100;
-       windowBounds.bottom = *height + 100;
+       windowBounds.right = mode->width + 100;
+       windowBounds.bottom = mode->height + 100;
        carbonError = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &windowBounds, &window);
        if (carbonError != noErr || window == NULL)
        {
        carbonError = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &windowBounds, &window);
        if (carbonError != noErr || window == NULL)
        {
@@ -610,9 +601,9 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                                                           GetEventTypeCount(winEvents), winEvents, window, NULL);
 
        // Create the desired attribute list
                                                           GetEventTypeCount(winEvents), winEvents, window, NULL);
 
        // Create the desired attribute list
-       VID_BuildAGLAttrib(attributes, bpp == 32, fullscreen, stereobuffer, samples);
+       VID_BuildAGLAttrib(attributes, mode->bitsperpixel == 32, mode->fullscreen, mode->stereobuffer, mode->samples);
 
 
-       if (!fullscreen)
+       if (!mode->fullscreen)
        {
                // Output to Window
                pixelFormat = qaglChoosePixelFormat(NULL, 0, attributes);
        {
                // Output to Window
                pixelFormat = qaglChoosePixelFormat(NULL, 0, attributes);
@@ -637,7 +628,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
 
                // TOCHECK: not sure whether or not it's necessary to change the resolution
                // "by hand", or if aglSetFullscreen does the job anyway
 
                // TOCHECK: not sure whether or not it's necessary to change the resolution
                // "by hand", or if aglSetFullscreen does the job anyway
-               refDisplayMode = CGDisplayBestModeForParametersAndRefreshRateWithProperty(mainDisplay, bpp, *width, *height, refreshrate, kCGDisplayModeIsSafeForHardware, NULL);
+               refDisplayMode = CGDisplayBestModeForParametersAndRefreshRateWithProperty(mainDisplay, mode->bitsperpixel, mode->width, mode->height, mode->refreshrate, kCGDisplayModeIsSafeForHardware, NULL);
                CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
                DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);
 
                CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
                DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);
 
@@ -678,9 +669,9 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
        qaglDestroyPixelFormat(pixelFormat);
 
        // Attempt fullscreen if requested
        qaglDestroyPixelFormat(pixelFormat);
 
        // Attempt fullscreen if requested
-       if (fullscreen)
+       if (mode->fullscreen)
        {
        {
-               qaglSetFullScreen (context, *width, *height, refreshrate, 0);
+               qaglSetFullScreen (context, mode->width, mode->height, mode->refreshrate, 0);
                error = qaglGetError();
                if (error != AGL_NO_ERROR)
                {
                error = qaglGetError();
                if (error != AGL_NO_ERROR)
                {
@@ -703,8 +694,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                }
        }
 
                }
        }
 
-       scr_width = *width;
-       scr_height = *height;
+       memset(&vid.support, 0, sizeof(vid.support));
 
        if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
                Sys_Error("glGetString not found in %s", gl_driver);
 
        if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
                Sys_Error("glGetString not found in %s", gl_driver);
@@ -714,7 +704,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
        gl_videosyncavailable = true;
 
        multithreadedgl = false;
        gl_videosyncavailable = true;
 
        multithreadedgl = false;
-       vid_isfullscreen = fullscreen;
+       vid_isfullscreen = mode->fullscreen;
        vid_usingmouse = false;
        vid_usinghidecursor = false;
        vid_hidden = false;
        vid_usingmouse = false;
        vid_usinghidecursor = false;
        vid_hidden = false;
index 9bbf5bcb027f10074066732c15ab4ab8985d38de..4fbb2d83592a81039c3bb56b82d05a2263a873ce 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -759,7 +759,7 @@ void VID_BuildGLXAttrib(int *attrib, qboolean stencil, qboolean stereobuffer, in
        *attrib++ = None;
 }
 
        *attrib++ = None;
 }
 
-int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
+qboolean VID_InitMode(viddef_mode_t *mode)
 {
        int i;
        int attrib[32];
 {
        int i;
        int attrib[32];
@@ -834,7 +834,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                return false;
        }
 
                return false;
        }
 
-       VID_BuildGLXAttrib(attrib, bpp == 32, stereobuffer, samples);
+       VID_BuildGLXAttrib(attrib, mode->bitsperpixel == 32, mode->stereobuffer, mode->samples);
        visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib);
        if (!visinfo)
        {
        visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib);
        if (!visinfo)
        {
@@ -842,7 +842,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                return false;
        }
 
                return false;
        }
 
-       if (fullscreen)
+       if (mode->fullscreen)
        {
                if(vid_netwmfullscreen.integer)
                {
        {
                if(vid_netwmfullscreen.integer)
                {
@@ -872,11 +872,11 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
 
                        for (i = 0; i < num_vidmodes; i++)
                        {
 
                        for (i = 0; i < num_vidmodes; i++)
                        {
-                               if (*width > vidmodes[i]->hdisplay || *height > vidmodes[i]->vdisplay)
+                               if (mode->width > vidmodes[i]->hdisplay || mode->height > vidmodes[i]->vdisplay)
                                        continue;
 
                                        continue;
 
-                               x = *width - vidmodes[i]->hdisplay;
-                               y = *height - vidmodes[i]->vdisplay;
+                               x = mode->width - vidmodes[i]->hdisplay;
+                               y = mode->height - vidmodes[i]->vdisplay;
                                dist = (x * x) + (y * y);
                                if (best_fit == -1 || dist < best_dist)
                                {
                                dist = (x * x) + (y * y);
                                if (best_fit == -1 || dist < best_dist)
                                {
@@ -890,8 +890,8 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                                // LordHavoc: changed from ActualWidth/ActualHeight =,
                                // to width/height =, so the window will take the full area of
                                // the mode chosen
                                // LordHavoc: changed from ActualWidth/ActualHeight =,
                                // to width/height =, so the window will take the full area of
                                // the mode chosen
-                               *width = vidmodes[best_fit]->hdisplay;
-                               *height = vidmodes[best_fit]->vdisplay;
+                               mode->width = vidmodes[best_fit]->hdisplay;
+                               mode->height = vidmodes[best_fit]->vdisplay;
 
                                // change to the mode
                                XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[best_fit]);
 
                                // change to the mode
                                XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[best_fit]);
@@ -901,7 +901,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
 
                                // Move the viewport to top left
                                XF86VidModeSetViewPort(vidx11_display, vidx11_screen, 0, 0);
 
                                // Move the viewport to top left
                                XF86VidModeSetViewPort(vidx11_display, vidx11_screen, 0, 0);
-                               Con_DPrintf("Using XVidMode fullscreen mode at %dx%d\n", *width, *height);
+                               Con_DPrintf("Using XVidMode fullscreen mode at %dx%d\n", mode->width, mode->height);
                        }
 
                        free(vidmodes);
                        }
 
                        free(vidmodes);
@@ -913,9 +913,9 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                        // use the full desktop resolution
                        vid_isfullscreen = true;
                        // width and height will be filled in later
                        // use the full desktop resolution
                        vid_isfullscreen = true;
                        // width and height will be filled in later
-                       *width = DisplayWidth(vidx11_display, vidx11_screen);
-                       *height = DisplayHeight(vidx11_display, vidx11_screen);
-                       Con_DPrintf("Using X11 fullscreen mode at %dx%d\n", *width, *height);
+                       mode->width = DisplayWidth(vidx11_display, vidx11_screen);
+                       mode->height = DisplayHeight(vidx11_display, vidx11_screen);
+                       Con_DPrintf("Using X11 fullscreen mode at %dx%d\n", mode->width, mode->height);
                }
        }
 
                }
        }
 
@@ -929,7 +929,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
        vidx11_colormap = attr.colormap = XCreateColormap(vidx11_display, root, visinfo->visual, AllocNone);
        attr.event_mask = X_MASK;
 
        vidx11_colormap = attr.colormap = XCreateColormap(vidx11_display, root, visinfo->visual, AllocNone);
        attr.event_mask = X_MASK;
 
-       if (fullscreen)
+       if (mode->fullscreen)
        {
                if(vid_isnetwmfullscreen)
                {
        {
                if(vid_isnetwmfullscreen)
                {
@@ -951,7 +951,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
        }
 
                mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
        }
 
-       win = XCreateWindow(vidx11_display, root, 0, 0, *width, *height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
+       win = XCreateWindow(vidx11_display, root, 0, 0, mode->width, mode->height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
 
        wmhints = XAllocWMHints();
        if(XpmCreatePixmapFromData(vidx11_display, win,
 
        wmhints = XAllocWMHints();
        if(XpmCreatePixmapFromData(vidx11_display, win,
@@ -966,8 +966,8 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
        szhints = XAllocSizeHints();
        if(vid_resizable.integer == 0 && !vid_isnetwmfullscreen)
        {
        szhints = XAllocSizeHints();
        if(vid_resizable.integer == 0 && !vid_isnetwmfullscreen)
        {
-               szhints->min_width = szhints->max_width = *width;
-               szhints->min_height = szhints->max_height = *height;
+               szhints->min_width = szhints->max_width = mode->width;
+               szhints->min_height = szhints->max_height = mode->height;
                szhints->flags |= PMinSize | PMaxSize;
        }
 
                szhints->flags |= PMinSize | PMaxSize;
        }
 
@@ -1022,8 +1022,6 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
        gl_platform = "GLX";
        gl_platformextensions = qglXQueryExtensionsString(vidx11_display, vidx11_screen);
 
        gl_platform = "GLX";
        gl_platformextensions = qglXQueryExtensionsString(vidx11_display, vidx11_screen);
 
-       gl_videosyncavailable = false;
-
 // COMMANDLINEOPTION: Linux GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
 // COMMANDLINEOPTION: BSD GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
 // COMMANDLINEOPTION: MacOSX GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
 // COMMANDLINEOPTION: Linux GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
 // COMMANDLINEOPTION: BSD GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
 // COMMANDLINEOPTION: MacOSX GLX: -nogetprocaddress disables GLX_ARB_get_proc_address (not required, more formal method of getting extension functions)
index 4313d9dc3f415da2e5e01f437564bf82b0fc59ed..2be1bf272f44d8943a77460e44932618f874166b 100644 (file)
@@ -74,7 +74,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 refreshrate, int stereobuffer, int samples)
+qboolean VID_InitMode(viddef_mode_t *mode)
 {
        return false;
 }
 {
        return false;
 }
index d18b5a42506c640b52b5c23275cfbd4c3b3c8a6c..c368bbc126f650cd257891f824c096a6479a4d46 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -656,15 +656,15 @@ static void VID_OutputVersion(void)
                                        version->major, version->minor, version->patch );
 }
 
                                        version->major, version->minor, version->patch );
 }
 
-int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
+qboolean VID_InitMode(viddef_mode_t *mode)
 {
        int i;
        static int notfirstvideomode = false;
        int flags = SDL_OPENGL;
        const char *drivername;
 
 {
        int i;
        static int notfirstvideomode = false;
        int flags = SDL_OPENGL;
        const char *drivername;
 
-       win_half_width = *width>>1;
-       win_half_height = *height>>1;
+       win_half_width = mode->width>>1;
+       win_half_height = mode->height>>1;
 
        if(vid_resizable.integer)
                flags |= SDL_RESIZABLE;
 
        if(vid_resizable.integer)
                flags |= SDL_RESIZABLE;
@@ -703,14 +703,14 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
        // Knghtbrd: should do platform-specific extension string function here
 
        vid_isfullscreen = false;
        // Knghtbrd: should do platform-specific extension string function here
 
        vid_isfullscreen = false;
-       if (fullscreen) {
+       if (mode->fullscreen) {
                flags |= SDL_FULLSCREEN;
                vid_isfullscreen = true;
        }
        //flags |= SDL_HWSURFACE;
 
        SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
                flags |= SDL_FULLSCREEN;
                vid_isfullscreen = true;
        }
        //flags |= SDL_HWSURFACE;
 
        SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
-       if (bpp >= 32)
+       if (mode->bitsperpixel >= 32)
        {
                SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
                SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
        {
                SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
                SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
@@ -726,26 +726,26 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra
                SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
                SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
        }
                SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
                SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
        }
-       if (stereobuffer)
+       if (mode->stereobuffer)
                SDL_GL_SetAttribute (SDL_GL_STEREO, 1);
        if (vid_vsync.integer)
                SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
        else
                SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 0);
                SDL_GL_SetAttribute (SDL_GL_STEREO, 1);
        if (vid_vsync.integer)
                SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
        else
                SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 0);
-       if (samples > 1)
+       if (mode->samples > 1)
        {
                SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1);
        {
                SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1);
-               SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, samples);
+               SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, mode->samples);
        }
 
        }
 
-       video_bpp = bpp;
+       video_bpp = mode->bitsperpixel;
        video_flags = flags;
        VID_SetIcon();
        video_flags = flags;
        VID_SetIcon();
-       screen = SDL_SetVideoMode(*width, *height, bpp, flags);
+       screen = SDL_SetVideoMode(mode->width, mode->height, mode->bitsperpixel, flags);
 
        if (screen == NULL)
        {
 
        if (screen == NULL)
        {
-               Con_Printf("Failed to set video mode to %ix%i: %s\n", *width, *height, SDL_GetError());
+               Con_Printf("Failed to set video mode to %ix%i: %s\n", mode->width, mode->height, SDL_GetError());
                VID_Shutdown();
                return false;
        }
                VID_Shutdown();
                return false;
        }
index f9cb06425916b5795c154be7607b94d020eb0c2a..c5af66c524166e5360a075dbf841c8c99dd92de8 100644 (file)
@@ -836,8 +836,6 @@ static dllfunction_t occlusionqueryfuncs[] =
 
 void VID_CheckExtensions(void)
 {
 
 void VID_CheckExtensions(void)
 {
-       gl_stencil = vid_bitsperpixel.integer == 32;
-
        // VorteX: reset extensions info cvar, it got filled by GL_CheckExtension
        Cvar_SetQuick(&gl_info_extensions, "");
 
        // VorteX: reset extensions info cvar, it got filled by GL_CheckExtension
        Cvar_SetQuick(&gl_info_extensions, "");
 
@@ -1240,37 +1238,44 @@ void VID_Shared_Init(void)
        Cvar_RegisterVariable(&gl_finish);
        Cmd_AddCommand("force_centerview", Force_CenterView_f, "recenters view (stops looking up/down)");
        Cmd_AddCommand("vid_restart", VID_Restart_f, "restarts video system (closes and reopens the window, restarts renderer)");
        Cvar_RegisterVariable(&gl_finish);
        Cmd_AddCommand("force_centerview", Force_CenterView_f, "recenters view (stops looking up/down)");
        Cmd_AddCommand("vid_restart", VID_Restart_f, "restarts video system (closes and reopens the window, restarts renderer)");
-       if (gamemode == GAME_GOODVSBAD2)
-               Cvar_Set("gl_combine", "0");
 }
 
 }
 
-int VID_Mode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
+int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate, int stereobuffer, int samples)
 {
 {
-       int requestedWidth = width;
-       int requestedHeight = height;
+       viddef_mode_t mode;
+       memset(&mode, 0, sizeof(mode));
+       mode.fullscreen = fullscreen;
+       mode.width = width;
+       mode.height = height;
+       mode.bitsperpixel = bpp;
+       mode.refreshrate = vid_userefreshrate.integer ? max(1, refreshrate) : 0;
+       mode.userefreshrate = vid_userefreshrate.integer;
+       mode.stereobuffer = stereobuffer;
+       mode.samples = samples;
        cl_ignoremousemoves = 2;
        cl_ignoremousemoves = 2;
-       Con_Printf("Initializing Video Mode: %s %dx%dx%dx%dhz%s%s\n", fullscreen ? "fullscreen" : "window", width, height, bpp, refreshrate, stereobuffer ? " stereo" : "", samples > 1 ? va(" (%ix AA)", samples) : "");
-       if (VID_InitMode(fullscreen, &width, &height, bpp, vid_userefreshrate.integer ? max(1, refreshrate) : 0, stereobuffer, samples))
+       if (VID_InitMode(&mode))
        {
        {
-               vid.fullscreen = fullscreen != 0;
-               vid.width = width;
-               vid.height = height;
-               vid.bitsperpixel = bpp;
-               vid.samples = samples;
-               vid.refreshrate = refreshrate;
-               vid.stereobuffer = stereobuffer != 0;
-               vid.userefreshrate = vid_userefreshrate.integer != 0;
-               Cvar_SetValueQuick(&vid_fullscreen, fullscreen);
-               Cvar_SetValueQuick(&vid_width, width);
-               Cvar_SetValueQuick(&vid_height, height);
-               Cvar_SetValueQuick(&vid_bitsperpixel, bpp);
-               Cvar_SetValueQuick(&vid_samples, samples);
+               // accept the (possibly modified) mode
+               vid.mode = mode;
+               vid.fullscreen     = vid.mode.fullscreen;
+               vid.width          = vid.mode.width;
+               vid.height         = vid.mode.height;
+               vid.bitsperpixel   = vid.mode.bitsperpixel;
+               vid.refreshrate    = vid.mode.refreshrate;
+               vid.userefreshrate = vid.mode.userefreshrate;
+               vid.stereobuffer   = vid.mode.stereobuffer;
+               vid.samples        = vid.mode.samples;
+               gl_stencil         = vid.mode.bitsperpixel > 16;
+               Con_Printf("Video Mode: %s %dx%dx%dx%.2fhz%s%s\n", mode.fullscreen ? "fullscreen" : "window", mode.width, mode.height, mode.bitsperpixel, mode.refreshrate, mode.stereobuffer ? " stereo" : "", mode.samples > 1 ? va(" (%ix AA)", mode.samples) : "");
+
+               Cvar_SetValueQuick(&vid_fullscreen, vid.mode.fullscreen);
+               Cvar_SetValueQuick(&vid_width, vid.mode.width);
+               Cvar_SetValueQuick(&vid_height, vid.mode.height);
+               Cvar_SetValueQuick(&vid_bitsperpixel, vid.mode.bitsperpixel);
+               Cvar_SetValueQuick(&vid_samples, vid.mode.samples);
                if(vid_userefreshrate.integer)
                if(vid_userefreshrate.integer)
-                       Cvar_SetValueQuick(&vid_refreshrate, refreshrate);
-               Cvar_SetValueQuick(&vid_stereobuffer, stereobuffer);
-
-               if(width != requestedWidth || height != requestedHeight)
-                       Con_Printf("Chose a similar video mode %dx%d instead of the requested mode %dx%d\n", width, height, requestedWidth, requestedHeight);
+                       Cvar_SetValueQuick(&vid_refreshrate, vid.mode.refreshrate);
+               Cvar_SetValueQuick(&vid_stereobuffer, vid.mode.stereobuffer);
 
                return true;
        }
 
                return true;
        }
@@ -1299,14 +1304,14 @@ void VID_Restart_f(void)
                return;
 
        Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp%s%s, to %s %dx%dx%dbpp%s%s.\n",
                return;
 
        Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp%s%s, to %s %dx%dx%dbpp%s%s.\n",
-               vid.fullscreen ? "fullscreen" : "window", vid.width, vid.height, vid.bitsperpixel, vid.fullscreen && vid_userefreshrate.integer ? va("x%ihz", vid.refreshrate) : "", vid.samples > 1 ? va(" (%ix AA)", vid.samples) : "",
-               vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_fullscreen.integer && vid_userefreshrate.integer ? va("x%ihz", vid_refreshrate.integer) : "", vid_samples.integer > 1 ? va(" (%ix AA)", vid_samples.integer) : "");
+               vid.mode.fullscreen ? "fullscreen" : "window", vid.mode.width, vid.mode.height, vid.mode.bitsperpixel, vid.mode.fullscreen && vid.mode.userefreshrate ? va("x%.2fhz", vid.mode.refreshrate) : "", vid.mode.samples > 1 ? va(" (%ix AA)", vid.mode.samples) : "",
+               vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_fullscreen.integer && vid_userefreshrate.integer ? va("x%.2fhz", vid_refreshrate.value) : "", vid_samples.integer > 1 ? va(" (%ix AA)", vid_samples.integer) : "");
        VID_CloseSystems();
        VID_Shutdown();
        VID_CloseSystems();
        VID_Shutdown();
-       if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer, vid_stereobuffer.integer, vid_samples.integer))
+       if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.value, vid_stereobuffer.integer, vid_samples.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, vid.refreshrate, vid.stereobuffer, vid.samples))
+               if (!VID_Mode(vid.mode.fullscreen, vid.mode.width, vid.mode.height, vid.mode.bitsperpixel, vid.mode.refreshrate, vid.mode.stereobuffer, vid.mode.samples))
                        Sys_Error("Unable to restore to last working video mode");
        }
        VID_OpenSystems();
                        Sys_Error("Unable to restore to last working video mode");
        }
        VID_OpenSystems();
@@ -1358,14 +1363,14 @@ void VID_Start(void)
                        Cvar_SetQuick(&vid_bitsperpixel, com_argv[i+1]);
        }
 
                        Cvar_SetQuick(&vid_bitsperpixel, com_argv[i+1]);
        }
 
-       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer, vid_stereobuffer.integer, vid_samples.integer);
+       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.value, vid_stereobuffer.integer, vid_samples.integer);
        if (!success)
        {
                Con_Print("Desired video mode fail, trying fallbacks...\n");
                for (i = 0;!success && vidfallbacks[i][0] != NULL;i++)
                {
                        Cvar_Set(vidfallbacks[i][0], vidfallbacks[i][1]);
        if (!success)
        {
                Con_Print("Desired video mode fail, trying fallbacks...\n");
                for (i = 0;!success && vidfallbacks[i][0] != NULL;i++)
                {
                        Cvar_Set(vidfallbacks[i][0], vidfallbacks[i][1]);
-                       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.integer, vid_stereobuffer.integer, vid_samples.integer);
+                       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.value, vid_stereobuffer.integer, vid_samples.integer);
                }
                if (!success)
                        Sys_Error("Video modes failed");
                }
                if (!success)
                        Sys_Error("Video modes failed");
index 4405533d6312422beed076fcccde81668b7a7d6e..1b6a27a1ef6624baac3a9d5b0acb1d4b1c7a37f2 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -787,7 +787,7 @@ void VID_Init(void)
        IN_Init();
 }
 
        IN_Init();
 }
 
-int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
+qboolean VID_InitMode(viddef_mode_t *mode)
 {
        int i;
        HDC hdc;
 {
        int i;
        HDC hdc;
@@ -827,6 +827,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
        float *af;
        int attribs[128];
        float attribsf[16];
        float *af;
        int attribs[128];
        float attribsf[16];
+       int bpp = mode->bitsperpixel;
+       int width = mode->width;
+       int height = mode->height;
+       int refreshrate = (int)floor(mode->refreshrate+0.5);
+       int stereobuffer = mode->stereobuffer;
+       int samples = mode->samples;
+       int fullscreen = mode->fullscreen;
 
        if (vid_initialized)
                Sys_Error("VID_InitMode called when video is already initialised");
 
        if (vid_initialized)
                Sys_Error("VID_InitMode called when video is already initialised");
@@ -928,8 +935,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                        foundmode = true;
                        gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
                        gdevmode.dmBitsPerPel = bpp;
                        foundmode = true;
                        gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
                        gdevmode.dmBitsPerPel = bpp;
-                       gdevmode.dmPelsWidth = *width;
-                       gdevmode.dmPelsHeight = *height;
+                       gdevmode.dmPelsWidth = width;
+                       gdevmode.dmPelsHeight = height;
                        gdevmode.dmSize = sizeof (gdevmode);
                        if(refreshrate)
                        {
                        gdevmode.dmSize = sizeof (gdevmode);
                        if(refreshrate)
                        {
@@ -962,13 +969,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                                                Con_Printf("wrong bpp\n");
                                        continue;
                                }
                                                Con_Printf("wrong bpp\n");
                                        continue;
                                }
-                               if(thismode.dmPelsWidth != (DWORD)*width)
+                               if(thismode.dmPelsWidth != (DWORD)width)
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong width\n");
                                        continue;
                                }
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong width\n");
                                        continue;
                                }
-                               if(thismode.dmPelsHeight != (DWORD)*height)
+                               if(thismode.dmPelsHeight != (DWORD)height)
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong height\n");
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong height\n");
@@ -1020,13 +1027,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                if (!foundmode)
                {
                        VID_Shutdown();
                if (!foundmode)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", *width, *height, bpp);
+                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", width, height, bpp);
                        return false;
                }
                else if(ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
                {
                        VID_Shutdown();
                        return false;
                }
                else if(ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", *width, *height, bpp);
+                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", width, height, bpp);
                        return false;
                }
 
                        return false;
                }
 
@@ -1059,8 +1066,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
 
        rect.top = 0;
        rect.left = 0;
 
        rect.top = 0;
        rect.left = 0;
-       rect.right = *width;
-       rect.bottom = *height;
+       rect.right = width;
+       rect.bottom = height;
        AdjustWindowRectEx(&rect, WindowStyle, false, 0);
 
        if (fullscreen)
        AdjustWindowRectEx(&rect, WindowStyle, false, 0);
 
        if (fullscreen)
@@ -1215,8 +1222,6 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
        // fix the leftover Alt from any Alt-Tab or the like that switched us away
        ClearAllStates ();
 
        // fix the leftover Alt from any Alt-Tab or the like that switched us away
        ClearAllStates ();
 
-       gl_videosyncavailable = false;
-
 // COMMANDLINEOPTION: Windows WGL: -novideosync disables WGL_EXT_swap_control
        gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);
 
 // COMMANDLINEOPTION: Windows WGL: -novideosync disables WGL_EXT_swap_control
        gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);