Backed out incomplete changes to GL driver
This commit is contained in:
parent
d5516e1b27
commit
3731f28892
3 changed files with 14 additions and 137 deletions
|
@ -234,10 +234,6 @@ CDriverGL::CDriverGL()
|
||||||
_CursorScale = 1.f;
|
_CursorScale = 1.f;
|
||||||
_MouseCaptured = false;
|
_MouseCaptured = false;
|
||||||
|
|
||||||
#if defined(NL_OS_WINDOWS)
|
|
||||||
_BorderlessFullscreen = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_NeedToRestaureGammaRamp = false;
|
_NeedToRestaureGammaRamp = false;
|
||||||
|
|
||||||
_win = EmptyWindow;
|
_win = EmptyWindow;
|
||||||
|
|
|
@ -996,12 +996,6 @@ private:
|
||||||
EWindowStyle getWindowStyle() const;
|
EWindowStyle getWindowStyle() const;
|
||||||
bool setWindowStyle(EWindowStyle windowStyle);
|
bool setWindowStyle(EWindowStyle windowStyle);
|
||||||
|
|
||||||
#if defined(NL_OS_WINDOWS)
|
|
||||||
static BOOL CALLBACK monitorEnumProcFullscreen(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData);
|
|
||||||
bool _BorderlessFullscreen;
|
|
||||||
#endif
|
|
||||||
std::string _CurrentDisplayDevice;
|
|
||||||
|
|
||||||
// Methods to manage screen resolutions
|
// Methods to manage screen resolutions
|
||||||
bool restoreScreenMode();
|
bool restoreScreenMode();
|
||||||
bool saveScreenMode();
|
bool saveScreenMode();
|
||||||
|
|
|
@ -1271,86 +1271,10 @@ static sint modeInfoToFrequency(XF86VidModeModeInfo *info)
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
#if defined(NL_OS_WINDOWS)
|
|
||||||
|
|
||||||
struct CMonitorEnumParams
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CDriverGL *Driver;
|
|
||||||
const char *DeviceName;
|
|
||||||
bool Success;
|
|
||||||
};
|
|
||||||
|
|
||||||
BOOL CALLBACK CDriverGL::monitorEnumProcFullscreen(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData)
|
|
||||||
{
|
|
||||||
CMonitorEnumParams *p = reinterpret_cast<CMonitorEnumParams *>(dwData);
|
|
||||||
|
|
||||||
MONITORINFOEXA monitorInfo;
|
|
||||||
memset(&monitorInfo, 0, sizeof(monitorInfo));
|
|
||||||
monitorInfo.cbSize = sizeof(monitorInfo);
|
|
||||||
GetMonitorInfoA(hMonitor, &monitorInfo);
|
|
||||||
nldebug("3D: Monitor: '%s'", monitorInfo.szDevice);
|
|
||||||
|
|
||||||
size_t devLen = strlen(monitorInfo.szDevice);
|
|
||||||
size_t targetLen = strlen(p->DeviceName);
|
|
||||||
|
|
||||||
nlassert(devLen < 32);
|
|
||||||
size_t minLen = min(devLen, targetLen);
|
|
||||||
if (!memcmp(monitorInfo.szDevice, p->DeviceName, minLen))
|
|
||||||
{
|
|
||||||
if (devLen == targetLen
|
|
||||||
|| (devLen < targetLen && (p->DeviceName[minLen] == '\\'))
|
|
||||||
|| (devLen > targetLen && (monitorInfo.szDevice[minLen] == '\\')))
|
|
||||||
{
|
|
||||||
nldebug("3D: Remapping '%s' to '%s'", p->DeviceName, monitorInfo.szDevice);
|
|
||||||
nldebug("3D: Found requested monitor at %i, %i", monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top);
|
|
||||||
p->Driver->_CurrentMode.Windowed = false;
|
|
||||||
p->Driver->setWindowStyle(CDriverGL::EWSWindowed);
|
|
||||||
p->Driver->setWindowSize(monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top);
|
|
||||||
LONG dwStyle = GetWindowLong(p->Driver->_win, GWL_STYLE);
|
|
||||||
SetWindowLong(p->Driver->_win, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
|
|
||||||
SetWindowPos(p->Driver->_win, NULL,
|
|
||||||
monitorInfo.rcMonitor.left,
|
|
||||||
monitorInfo.rcMonitor.top,
|
|
||||||
monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left,
|
|
||||||
monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top,
|
|
||||||
SWP_FRAMECHANGED);
|
|
||||||
p->Driver->_WindowX = monitorInfo.rcMonitor.left;
|
|
||||||
p->Driver->_WindowY = monitorInfo.rcMonitor.top;
|
|
||||||
p->Driver->_CurrentDisplayDevice = std::string(p->DeviceName);
|
|
||||||
p->Driver->_BorderlessFullscreen = true;
|
|
||||||
p->Driver->_CurrentMode.Windowed = false;
|
|
||||||
p->Success = true;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p->Success = false;
|
|
||||||
return TRUE; // continue
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
|
|
||||||
bool CDriverGL::setScreenMode(const GfxMode &mode)
|
bool CDriverGL::setScreenMode(const GfxMode &mode)
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CDriverGL_setScreenMode)
|
H_AUTO_OGL(CDriverGL_setScreenMode)
|
||||||
|
|
||||||
nldebug("3D: setScreenMode");
|
|
||||||
|
|
||||||
#if defined(NL_OS_WINDOWS)
|
|
||||||
if (_BorderlessFullscreen)
|
|
||||||
{
|
|
||||||
_BorderlessFullscreen = false;
|
|
||||||
LONG dwStyle = GetWindowLong(_win, GWL_STYLE);
|
|
||||||
dwStyle |= WS_OVERLAPPEDWINDOW;
|
|
||||||
if (!_Resizable) dwStyle ^= WS_MAXIMIZEBOX|WS_THICKFRAME;
|
|
||||||
SetWindowLong(_win, GWL_STYLE, dwStyle);
|
|
||||||
SetWindowPos(_win, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
|
||||||
_CurrentMode.Windowed = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mode.Windowed)
|
if (mode.Windowed)
|
||||||
{
|
{
|
||||||
// if fullscreen, switch back to desktop screen mode
|
// if fullscreen, switch back to desktop screen mode
|
||||||
|
@ -1360,17 +1284,13 @@ bool CDriverGL::setScreenMode(const GfxMode &mode)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_CurrentDisplayDevice != mode.DisplayDevice)
|
|
||||||
restoreScreenMode();
|
|
||||||
|
|
||||||
// save previous screen mode only if switching from windowed to fullscreen
|
// save previous screen mode only if switching from windowed to fullscreen
|
||||||
if (_CurrentMode.Windowed)
|
if (_CurrentMode.Windowed)
|
||||||
saveScreenMode();
|
saveScreenMode();
|
||||||
|
|
||||||
// if switching exactly to the same screen mode, doesn't change it
|
// if switching exactly to the same screen mode, doesn't change it
|
||||||
GfxMode previousMode;
|
GfxMode previousMode;
|
||||||
if (_CurrentDisplayDevice == mode.DisplayDevice
|
if (getCurrentScreenMode(previousMode)
|
||||||
&& getCurrentScreenMode(previousMode)
|
|
||||||
&& mode.Width == previousMode.Width
|
&& mode.Width == previousMode.Width
|
||||||
&& mode.Height == previousMode.Height
|
&& mode.Height == previousMode.Height
|
||||||
&& mode.Depth == previousMode.Depth
|
&& mode.Depth == previousMode.Depth
|
||||||
|
@ -1379,9 +1299,7 @@ bool CDriverGL::setScreenMode(const GfxMode &mode)
|
||||||
|
|
||||||
#if defined(NL_OS_WINDOWS)
|
#if defined(NL_OS_WINDOWS)
|
||||||
|
|
||||||
const char *deviceName = mode.DisplayDevice.c_str();
|
DEVMODE devMode;
|
||||||
|
|
||||||
DEVMODEA devMode;
|
|
||||||
memset(&devMode, 0, sizeof(DEVMODE));
|
memset(&devMode, 0, sizeof(DEVMODE));
|
||||||
devMode.dmSize = sizeof(DEVMODE);
|
devMode.dmSize = sizeof(DEVMODE);
|
||||||
devMode.dmDriverExtra = 0;
|
devMode.dmDriverExtra = 0;
|
||||||
|
@ -1389,43 +1307,23 @@ bool CDriverGL::setScreenMode(const GfxMode &mode)
|
||||||
devMode.dmPelsWidth = mode.Width;
|
devMode.dmPelsWidth = mode.Width;
|
||||||
devMode.dmPelsHeight = mode.Height;
|
devMode.dmPelsHeight = mode.Height;
|
||||||
|
|
||||||
if (mode.Depth > 0)
|
if(mode.Depth > 0)
|
||||||
{
|
{
|
||||||
devMode.dmBitsPerPel = mode.Depth;
|
devMode.dmBitsPerPel = mode.Depth;
|
||||||
devMode.dmFields |= DM_BITSPERPEL;
|
devMode.dmFields |= DM_BITSPERPEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.Frequency > 0)
|
if(mode.Frequency > 0)
|
||||||
{
|
{
|
||||||
devMode.dmDisplayFrequency = mode.Frequency;
|
devMode.dmDisplayFrequency = mode.Frequency;
|
||||||
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceName[0])
|
if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
||||||
{
|
|
||||||
// First attempt exclusive fullscreen
|
|
||||||
nldebug("3D: ChangeDisplaySettingsEx");
|
|
||||||
LONG resex;
|
|
||||||
if ((resex = ChangeDisplaySettingsExA(deviceName, &devMode, NULL, CDS_FULLSCREEN, NULL)) != DISP_CHANGE_SUCCESSFUL)
|
|
||||||
{
|
|
||||||
nlwarning("3D: Fullscreen mode switch failed (%i)", (sint)resex);
|
|
||||||
// Workaround, resize to monitor and make borderless
|
|
||||||
CMonitorEnumParams p;
|
|
||||||
p.DeviceName = deviceName;
|
|
||||||
p.Driver = this;
|
|
||||||
EnumDisplayMonitors(NULL, NULL, monitorEnumProcFullscreen, (LPARAM)&p);
|
|
||||||
return p.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nldebug("3D: ChangeDisplaySettings");
|
|
||||||
if (ChangeDisplaySettingsA(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
|
||||||
{
|
{
|
||||||
nlwarning("3D: Fullscreen mode switch failed");
|
nlwarning("3D: Fullscreen mode switch failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(NL_OS_MAC)
|
#elif defined(NL_OS_MAC)
|
||||||
|
|
||||||
|
@ -1830,11 +1728,7 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
|
||||||
dwNewStyle |= WS_VISIBLE;
|
dwNewStyle |= WS_VISIBLE;
|
||||||
|
|
||||||
if (dwStyle != dwNewStyle)
|
if (dwStyle != dwNewStyle)
|
||||||
{
|
|
||||||
SetWindowLong(_win, GWL_STYLE, dwNewStyle);
|
SetWindowLong(_win, GWL_STYLE, dwNewStyle);
|
||||||
if (windowStyle == EWSWindowed)
|
|
||||||
SetWindowPos(_win, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (windowStyle == EWSMaximized && isVisible && !isMaximized)
|
// if (windowStyle == EWSMaximized && isVisible && !isMaximized)
|
||||||
// ShowWindow(_hWnd, SW_SHOWMAXIMIZED);
|
// ShowWindow(_hWnd, SW_SHOWMAXIMIZED);
|
||||||
|
@ -1962,15 +1856,11 @@ bool CDriverGL::setMode(const GfxMode& mode)
|
||||||
&& ScreenToClient(_win, &cursorPos);
|
&& ScreenToClient(_win, &cursorPos);
|
||||||
sint curX = (sint)cursorPos.x * (sint)mode.Width;
|
sint curX = (sint)cursorPos.x * (sint)mode.Width;
|
||||||
sint curY = (sint)cursorPos.y * (sint)mode.Height;
|
sint curY = (sint)cursorPos.y * (sint)mode.Height;
|
||||||
if (_BorderlessFullscreen)
|
|
||||||
ReleaseCapture();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!setScreenMode(mode))
|
if (!setScreenMode(mode))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!_BorderlessFullscreen)
|
|
||||||
{
|
|
||||||
// when changing window style, it's possible system change window size too
|
// when changing window style, it's possible system change window size too
|
||||||
setWindowStyle(mode.Windowed ? EWSWindowed : EWSFullscreen);
|
setWindowStyle(mode.Windowed ? EWSWindowed : EWSFullscreen);
|
||||||
|
|
||||||
|
@ -1979,7 +1869,6 @@ bool CDriverGL::setMode(const GfxMode& mode)
|
||||||
|
|
||||||
setWindowSize(mode.Width, mode.Height);
|
setWindowSize(mode.Width, mode.Height);
|
||||||
setWindowPos(_WindowX, _WindowY);
|
setWindowPos(_WindowX, _WindowY);
|
||||||
}
|
|
||||||
|
|
||||||
switch (_CurrentMode.Depth)
|
switch (_CurrentMode.Depth)
|
||||||
{
|
{
|
||||||
|
@ -1996,8 +1885,6 @@ bool CDriverGL::setMode(const GfxMode& mode)
|
||||||
cursorPos.y = curY / (sint)mode.Height;
|
cursorPos.y = curY / (sint)mode.Height;
|
||||||
ClientToScreen(_win, &cursorPos);
|
ClientToScreen(_win, &cursorPos);
|
||||||
SetCursorPos(cursorPos.x, cursorPos.y);
|
SetCursorPos(cursorPos.x, cursorPos.y);
|
||||||
if (_BorderlessFullscreen)
|
|
||||||
SetCapture(_win);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue