From: divverent Date: Sat, 31 Jan 2009 11:12:13 +0000 (+0000) Subject: more fullscreen cleanup X-Git-Tag: xonotic-v0.1.0preview~1906 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=49b02ed536f0537ee36b6f21a2f130aad56d428d more fullscreen cleanup git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8688 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/vid.h b/vid.h index 215ffac2..93c6db49 100644 --- 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) diff --git a/vid_agl.c b/vid_agl.c index 88e33a16..775e0175 100644 --- 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); diff --git a/vid_glx.c b/vid_glx.c index 395bb605..433fb4ed 100644 --- 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; } diff --git a/vid_null.c b/vid_null.c index 6a6b8929..bade6d07 100644 --- a/vid_null.c +++ b/vid_null.c @@ -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; } diff --git a/vid_sdl.c b/vid_sdl.c index d6123be7..342b7acf 100644 --- 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; } diff --git a/vid_shared.c b/vid_shared.c index d538f7cf..5edba670 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -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 diff --git a/vid_wgl.c b/vid_wgl.c index 9d918412..752241d1 100644 --- 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)