From 102822ff009370e51c41c7e949a3c957eeabbd7b Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 1 Jun 2010 11:37:11 +0200 Subject: [PATCH] Fixed: #926 fixed XF86VidModeModeInfo creation, should work on 64b --- .../src/3d/driver/opengl/driver_opengl.cpp | 67 ++++++++++--------- code/nel/src/3d/driver/opengl/driver_opengl.h | 2 + 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 618db783c..e5d54e894 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -1466,6 +1466,37 @@ static void modifyStyle (HWND hWnd, int nStyleOffset, LONG_PTR dwRemove, LONG_PT } #endif +// -------------------------------------------------- +void CDriverGL::switchBackToOldMode() +{ +#ifdef NL_OS_WINDOWS + ChangeDisplaySettings(&_OldScreenMode, 0); +#elif defined(XF86VIDMODE) + XF86VidModeModeInfo info; + nlinfo("3D: Switching back to original mode"); + + // This is UGLY + info.dotclock = _OldDotClock; + info.hdisplay = _OldScreenMode.hdisplay; + info.hsyncstart = _OldScreenMode.hsyncstart; + info.hsyncend = _OldScreenMode.hsyncend; + info.htotal = _OldScreenMode.htotal; + info.vdisplay = _OldScreenMode.vdisplay; + info.vsyncstart = _OldScreenMode.vsyncstart; + info.vsyncend = _OldScreenMode.vsyncend; + info.vtotal = _OldScreenMode.vtotal; + info.flags = _OldScreenMode.flags; + info.privsize = _OldScreenMode.privsize; + info.c_private = _OldScreenMode.c_private; + + nlinfo("3D: Switching back mode to %dx%d", info.hdisplay, info.vdisplay); + XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &info); + nlinfo("3D: Switching back viewport to %d,%d",_OldX, _OldY); + XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), _OldX, _OldY); +#endif // XF86VIDMODE +} + + // -------------------------------------------------- bool CDriverGL::setMode(const GfxMode& mode) { @@ -1475,7 +1506,7 @@ bool CDriverGL::setMode(const GfxMode& mode) { if (_FullScreen) { - ChangeDisplaySettings (NULL,0); + switchBackToOldMode(); modifyStyle(_hWnd, GWL_STYLE, WS_POPUP, WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS); } _WindowWidth = mode.Width; @@ -1596,20 +1627,7 @@ bool CDriverGL::setMode(const GfxMode& mode) } } else if (mode.Windowed == _FullScreen) - { - XF86VidModeModeInfo info; - nlinfo("3D: Switching back to original mode"); - - // This is a bit ugly - a quick hack to copy the ModeLine structure - // into the modeInfo structure. - memcpy((XF86VidModeModeLine *)((char *)&info + sizeof(info.dotclock)),&_OldScreenMode, sizeof(XF86VidModeModeLine)); - info.dotclock = _OldDotClock; - - nlinfo("3D: Switching back mode to %dx%d", info.hdisplay, info.vdisplay); - XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &info); - nlinfo("3D: Switching back viewport to %d,%d",_OldX, _OldY); - XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), _OldX, _OldY); - } + switchBackToOldMode(); #endif // XF86VIDMODE // Update WM hints (update size and disallow resizing) @@ -2166,7 +2184,7 @@ bool CDriverGL::release() if(_FullScreen) { - ChangeDisplaySettings(&_OldScreenMode, 0); + switchBackToOldMode(); _FullScreen= false; } } @@ -2199,28 +2217,15 @@ bool CDriverGL::release() nlwarning("OpenGL Driver: Missing Mac Implementation"); #elif defined (NL_OS_UNIX) - -#ifdef XF86VIDMODE if(_FullScreen) { - XF86VidModeModeInfo info; - nlinfo("3D: Switching back to original mode"); - - // This is a bit ugly - a quick hack to copy the ModeLine structure - // into the modeInfo structure. - memcpy((XF86VidModeModeLine *)((char *)&info + sizeof(info.dotclock)),&_OldScreenMode, sizeof(XF86VidModeModeLine)); - info.dotclock = _OldDotClock; - - nlinfo("3D: Switching back mode to %dx%d", info.hdisplay, info.vdisplay); - XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &info); - nlinfo("3D: Switching back viewport to %d,%d",_OldX, _OldY); - XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), _OldX, _OldY); + switchBackToOldMode(); + // Ungrab the keyboard (probably not necessary); XUnmapWindow(dpy, win); XSync(dpy, True); XUngrabKeyboard(dpy, CurrentTime); } -#endif // XF86VIDMODE if (ctx) { diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 1d981d170..aad98fc5d 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -841,6 +841,8 @@ private: bool _CurrentGlNormalize; private: + void switchBackToOldMode(); + // Get the proj matrix setupped in GL void refreshProjMatrixFromGL();