]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
more fullscreen cleanup
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 31 Jan 2009 11:12:13 +0000 (11:12 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 31 Jan 2009 11:12:13 +0000 (11:12 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8688 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 215ffac21e68e7aadb716292939717e98c4e2d98..93c6db495e9617b4425144a55dc408fe7150526d 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -127,7 +127,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
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples);
+int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples);
 // allocates and opens an appropriate OpenGL context (and its window)
 
 
index 88e33a16e68e8a60971561f4af2f8063c49aec89..775e01751584118265cfe1b7b0898f523cda572e 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -531,7 +531,7 @@ static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscr
        *attrib++ = AGL_NONE;
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
+int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
 {
     const EventTypeSpec winEvents[] =
        {
@@ -583,8 +583,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
        // 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 = *width + 100;
+       windowBounds.bottom = *height + 100;
        carbonError = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &windowBounds, &window);
        if (carbonError != noErr || window == NULL)
        {
@@ -629,7 +629,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
 
                // TOCHECK: not sure whether or not it's necessary to change the resolution
                // "by hand", or if aglSetFullscreen does the job anyway
-               refDisplayMode = CGDisplayBestModeForParametersAndRefreshRate(mainDisplay, bpp, width, height, refreshrate, NULL);
+               refDisplayMode = CGDisplayBestModeForParametersAndRefreshRate(mainDisplay, bpp, *width, *height, refreshrate, NULL);
                CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
                DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);
 
@@ -672,7 +672,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
        // Attempt fullscreen if requested
        if (fullscreen)
        {
-               qaglSetFullScreen (context, width, height, refreshrate, 0);
+               qaglSetFullScreen (context, *width, *height, refreshrate, 0);
                error = qaglGetError();
                if (error != AGL_NO_ERROR)
                {
@@ -695,8 +695,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                }
        }
 
-       scr_width = width;
-       scr_height = height;
+       scr_width = *width;
+       scr_height = *height;
 
        if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
                Sys_Error("glGetString not found in %s", gl_driver);
index 395bb605e6c8a96db3a5753b06b7cb62da12e2a0..433fb4ed7db52e5fc2279ec3c16bf8fbc09f463e 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -475,10 +475,14 @@ static void HandleEvents(void)
                        // window changed size/location
                        win_x = event.xconfigure.x;
                        win_y = event.xconfigure.y;
-                       if(vid_resizable.integer < 2)
+                       if(vid_resizable.integer < 2 || vid_isnetwmfullscreen)
                        {
                                vid.width = event.xconfigure.width;
                                vid.height = event.xconfigure.height;
+                               if(vid_isnetwmfullscreen)
+                                       Con_Printf("NetWM fullscreen: actually using resolution %dx%d\n", vid.width, vid.height);
+                               else
+                                       Con_DPrintf("Updating to ConfigureNotify resolution %dx%d\n", vid.width, vid.height);
                        }
                        break;
                case DestroyNotify:
@@ -755,7 +759,7 @@ void VID_BuildGLXAttrib(int *attrib, qboolean stencil, qboolean stereobuffer, in
        *attrib++ = None;
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
+int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
 {
        int i;
        int attrib[32];
@@ -846,6 +850,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                        vid_isnetwmfullscreen = true;
                        vid_isfullscreen = true;
                        // width and height will be filled in later
+                       Con_DPrintf("Using NetWM fullscreen mode\n");
                }
 
                if(!vid_isfullscreen && vidmode_ext)
@@ -867,11 +872,11 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
 
                        for (i = 0; i < num_vidmodes; i++)
                        {
-                               if (width > vidmodes[i]->hdisplay || height > vidmodes[i]->vdisplay)
+                               if (*width > vidmodes[i]->hdisplay || *height > vidmodes[i]->vdisplay)
                                        continue;
 
-                               x = width - vidmodes[i]->hdisplay;
-                               y = height - vidmodes[i]->vdisplay;
+                               x = *width - vidmodes[i]->hdisplay;
+                               y = *height - vidmodes[i]->vdisplay;
                                dist = (x * x) + (y * y);
                                if (best_fit == -1 || dist < best_dist)
                                {
@@ -885,8 +890,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                                // 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;
+                               *width = vidmodes[best_fit]->hdisplay;
+                               *height = vidmodes[best_fit]->vdisplay;
 
                                // change to the mode
                                XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[best_fit]);
@@ -896,6 +901,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
 
                                // 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);
                        }
 
                        free(vidmodes);
@@ -907,8 +913,9 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                        // 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);
+                       *width = DisplayWidth(vidx11_display, vidx11_screen);
+                       *height = DisplayHeight(vidx11_display, vidx11_screen);
+                       Con_DPrintf("Using X11 fullscreen mode at %dx%d\n", *width, *height);
                }
        }
 
@@ -944,7 +951,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                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, *width, *height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
 
        wmhints = XAllocWMHints();
        if(XpmCreatePixmapFromData(vidx11_display, win,
@@ -959,8 +966,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
        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 = *width;
+               szhints->min_height = szhints->max_height = *height;
                szhints->flags |= PMinSize | PMaxSize;
        }
 
@@ -1038,6 +1045,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
        if (!vid_x11_dgasupported)
                Con_Print( "Failed to detect XF86DGA Mouse extension\n" );
 #endif
+
        GL_Init();
        return true;
 }
index 6a6b8929360c5bf19de061e23290e9fc28c080e0..bade6d07d7782c057518dab9c6fb98f19c6c6715 100644 (file)
@@ -74,7 +74,7 @@ void VID_Init(void)
        InitSig(); // trap evil signals
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
+int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
 {
        return false;
 }
index d6123be70d8829eb87be09fc6b8b51536d7d1a82..342b7acf0d93649daa441bfe1fedd31c47c93eed 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -624,15 +624,15 @@ static void VID_OutputVersion()
                                        version->major, version->minor, version->patch );
 }
 
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
+int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
 {
        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 = *width>>1;
+       win_half_height = *height>>1;
 
        if(vid_resizable.integer)
                flags |= SDL_RESIZABLE;
@@ -709,11 +709,11 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
        video_bpp = bpp;
        video_flags = flags;
        VID_SetIcon();
-       screen = SDL_SetVideoMode(width, height, bpp, flags);
+       screen = SDL_SetVideoMode(*width, *height, bpp, flags);
 
        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", *width, *height, SDL_GetError());
                VID_Shutdown();
                return false;
        }
index d538f7cf7d4caff2af988e2e9c38b44cf7dcca09..5edba6706b02e1faf57d244bc7ce4126eebae742 100644 (file)
@@ -1069,9 +1069,11 @@ void VID_Shared_Init(void)
 
 int VID_Mode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
 {
+       int requestedWidth = width;
+       int requestedHeight = height;
        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(fullscreen, &width, &height, bpp, vid_userefreshrate.integer ? max(1, refreshrate) : 0, stereobuffer, samples))
        {
                vid.fullscreen = fullscreen;
                vid.width = width;
@@ -1089,6 +1091,10 @@ int VID_Mode(int fullscreen, int width, int height, int bpp, int refreshrate, in
                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);
+
                return true;
        }
        else
index 9d9184128ac34362a74e0dfce185503b770d927b..752241d1fe47ef19935e1198e07f1d3a6b8a99de 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -781,7 +781,7 @@ void VID_Init(void)
        IN_Init();
 }
 
-int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
+int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
 {
        int i;
        HDC hdc;
@@ -922,8 +922,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
                        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)
                        {
@@ -1014,13 +1014,13 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
                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();
-                       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;
                }
 
@@ -1053,8 +1053,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
 
        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)