// 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)
*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[] =
{
// 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)
{
// 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);
// 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)
{
}
}
- 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);
// 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:
*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];
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)
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)
{
// 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]);
// 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);
// 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);
}
}
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,
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;
}
if (!vid_x11_dgasupported)
Con_Print( "Failed to detect XF86DGA Mouse extension\n" );
#endif
+
GL_Init();
return true;
}
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;
}
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;
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;
}
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;
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
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;
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)
{
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;
}
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)