From: havoc Date: Mon, 7 Dec 2009 15:50:45 +0000 (+0000) Subject: changed VID_InitMode to take a viddef_mode_t structure which contains X-Git-Tag: xonotic-v0.1.0preview~1094 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=779192f83f5c0e6ef6c692f7c116afaa55b51c93 changed VID_InitMode to take a viddef_mode_t structure which contains 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 --- diff --git a/vid.h b/vid.h index ba6d060a..1b991403 100644 --- 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; +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 + viddef_mode_t mode; 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 -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) diff --git a/vid_agl.c b/vid_agl.c index c5c55fa2..af5c8b7f 100644 --- a/vid_agl.c +++ b/vid_agl.c @@ -68,8 +68,6 @@ static qboolean vid_usingvsync = false; 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"}; @@ -99,13 +97,6 @@ io_connect_t IN_GetIOHandle(void) 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) @@ -539,9 +530,9 @@ 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) +qboolean VID_InitMode(viddef_mode_t *mode) { - const EventTypeSpec winEvents[] = + const EventTypeSpec winEvents[] = { { 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; - 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) { @@ -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 - 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); @@ -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 - 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); @@ -678,9 +669,9 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra 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) { @@ -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); @@ -714,7 +704,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra gl_videosyncavailable = true; multithreadedgl = false; - vid_isfullscreen = fullscreen; + vid_isfullscreen = mode->fullscreen; vid_usingmouse = false; vid_usinghidecursor = false; vid_hidden = false; diff --git a/vid_glx.c b/vid_glx.c index 9bbf5bcb..4fbb2d83 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -759,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) +qboolean VID_InitMode(viddef_mode_t *mode) { int i; int attrib[32]; @@ -834,7 +834,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra 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) { @@ -842,7 +842,7 @@ int VID_InitMode(int fullscreen, int *width, int *height, int bpp, int refreshra return false; } - if (fullscreen) + if (mode->fullscreen) { 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++) { - if (*width > vidmodes[i]->hdisplay || *height > vidmodes[i]->vdisplay) + if (mode->width > vidmodes[i]->hdisplay || mode->height > vidmodes[i]->vdisplay) 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) { @@ -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 - *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]); @@ -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); - 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); @@ -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 - *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; - if (fullscreen) + if (mode->fullscreen) { 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; } - 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, @@ -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->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; } @@ -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_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) diff --git a/vid_null.c b/vid_null.c index 4313d9dc..2be1bf27 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) +qboolean VID_InitMode(viddef_mode_t *mode) { return false; } diff --git a/vid_sdl.c b/vid_sdl.c index d18b5a42..c368bbc1 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -656,15 +656,15 @@ static void VID_OutputVersion(void) 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; - 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; @@ -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; - if (fullscreen) { + if (mode->fullscreen) { 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); @@ -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); } - 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); - if (samples > 1) + if (mode->samples > 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(); - screen = SDL_SetVideoMode(*width, *height, bpp, flags); + screen = SDL_SetVideoMode(mode->width, mode->height, mode->bitsperpixel, 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", mode->width, mode->height, SDL_GetError()); VID_Shutdown(); return false; } diff --git a/vid_shared.c b/vid_shared.c index f9cb0642..c5af66c5 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -836,8 +836,6 @@ static dllfunction_t occlusionqueryfuncs[] = 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, ""); @@ -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)"); - 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; - 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) - 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; } @@ -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", - 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(); - 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"); - 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(); @@ -1358,14 +1363,14 @@ void VID_Start(void) 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]); - 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"); diff --git a/vid_wgl.c b/vid_wgl.c index 4405533d..1b6a27a1 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -787,7 +787,7 @@ void VID_Init(void) 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; @@ -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]; + 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"); @@ -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; - gdevmode.dmPelsWidth = *width; - gdevmode.dmPelsHeight = *height; + gdevmode.dmPelsWidth = width; + gdevmode.dmPelsHeight = height; 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; } - if(thismode.dmPelsWidth != (DWORD)*width) + if(thismode.dmPelsWidth != (DWORD)width) { 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"); @@ -1020,13 +1027,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr 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; } @@ -1059,8 +1066,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr 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) @@ -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 (); - gl_videosyncavailable = false; - // COMMANDLINEOPTION: Windows WGL: -novideosync disables WGL_EXT_swap_control gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);