Clean handling of display mode switching in client
This commit is contained in:
parent
c2d39e8bdf
commit
60c4e36fec
10 changed files with 31 additions and 16 deletions
|
@ -73,7 +73,7 @@ public:
|
||||||
void recycleTextures();
|
void recycleTextures();
|
||||||
|
|
||||||
/// Attach the driver to the display
|
/// Attach the driver to the display
|
||||||
virtual void attachToDisplay();
|
virtual bool attachToDisplay();
|
||||||
/// Detach the driver from the display
|
/// Detach the driver from the display
|
||||||
virtual void detachFromDisplay();
|
virtual void detachFromDisplay();
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,8 @@ public:
|
||||||
/// Sets driver and generates necessary render targets
|
/// Sets driver and generates necessary render targets
|
||||||
virtual void setDriver(NL3D::UDriver *driver) = 0;
|
virtual void setDriver(NL3D::UDriver *driver) = 0;
|
||||||
|
|
||||||
/// Attach the driver to the display
|
/// Attach the driver to the display, return true if attached
|
||||||
virtual void attachToDisplay() = 0;
|
virtual bool attachToDisplay() = 0;
|
||||||
/// Detach the driver from the display
|
/// Detach the driver from the display
|
||||||
virtual void detachFromDisplay() = 0;
|
virtual void detachFromDisplay() = 0;
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
virtual void setDriver(NL3D::UDriver *driver);
|
virtual void setDriver(NL3D::UDriver *driver);
|
||||||
|
|
||||||
/// Attach the driver to the display
|
/// Attach the driver to the display
|
||||||
virtual void attachToDisplay();
|
virtual bool attachToDisplay();
|
||||||
/// Detach the driver from the display
|
/// Detach the driver from the display
|
||||||
virtual void detachFromDisplay();
|
virtual void detachFromDisplay();
|
||||||
|
|
||||||
|
|
|
@ -2419,7 +2419,7 @@ void CDriverGL::setWindowPos(sint32 x, sint32 y)
|
||||||
&& GetCursorPos(&cursorPos)
|
&& GetCursorPos(&cursorPos)
|
||||||
&& ScreenToClient(_win, &cursorPos);
|
&& ScreenToClient(_win, &cursorPos);
|
||||||
|
|
||||||
SetWindowPos(_win, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
|
SetWindowPos(_win, NULL, x, y, 0, 0, /*SWP_NOZORDER | SWP_NOACTIVATE |*/ SWP_NOSIZE);
|
||||||
|
|
||||||
if (cursorPosOk)
|
if (cursorPosOk)
|
||||||
{
|
{
|
||||||
|
|
|
@ -211,9 +211,9 @@ void CStereoDebugger::setDriver(NL3D::UDriver *driver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStereoDebugger::attachToDisplay()
|
bool CStereoDebugger::attachToDisplay()
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStereoDebugger::detachFromDisplay()
|
void CStereoDebugger::detachFromDisplay()
|
||||||
|
|
|
@ -444,7 +444,7 @@ bool CStereoOVR::getScreenResolution(uint &width, uint &height)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStereoOVR::attachToDisplay()
|
bool CStereoOVR::attachToDisplay()
|
||||||
{
|
{
|
||||||
nldebug("OVR: Attach to display '%s'", m_DevicePtr->DisplayDeviceName);
|
nldebug("OVR: Attach to display '%s'", m_DevicePtr->DisplayDeviceName);
|
||||||
|
|
||||||
|
@ -461,6 +461,7 @@ void CStereoOVR::attachToDisplay()
|
||||||
mode.Height = m_DevicePtr->Resolution.h;
|
mode.Height = m_DevicePtr->Resolution.h;
|
||||||
m_Driver->setMode(mode);
|
m_Driver->setMode(mode);
|
||||||
m_AttachedDisplay = true;
|
m_AttachedDisplay = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStereoOVR::detachFromDisplay()
|
void CStereoOVR::detachFromDisplay()
|
||||||
|
|
|
@ -206,9 +206,13 @@ void connectionRestaureVideoMode ()
|
||||||
if (ClientCfg.Width < 800) ClientCfg.Width = 800;
|
if (ClientCfg.Width < 800) ClientCfg.Width = 800;
|
||||||
if (ClientCfg.Height < 600) ClientCfg.Height = 600;
|
if (ClientCfg.Height < 600) ClientCfg.Height = 600;
|
||||||
|
|
||||||
if ((ClientCfg.Windowed != mode.Windowed) ||
|
if (StereoDisplay)
|
||||||
|
StereoDisplayAttached = StereoDisplay->attachToDisplay();
|
||||||
|
|
||||||
|
if (!StereoDisplayAttached && (
|
||||||
|
(ClientCfg.Windowed != mode.Windowed) ||
|
||||||
(ClientCfg.Width != mode.Width) ||
|
(ClientCfg.Width != mode.Width) ||
|
||||||
(ClientCfg.Height != mode.Height))
|
(ClientCfg.Height != mode.Height)))
|
||||||
{
|
{
|
||||||
mode.Windowed = ClientCfg.Windowed;
|
mode.Windowed = ClientCfg.Windowed;
|
||||||
mode.Depth = uint8(ClientCfg.Depth);
|
mode.Depth = uint8(ClientCfg.Depth);
|
||||||
|
@ -218,9 +222,6 @@ void connectionRestaureVideoMode ()
|
||||||
setVideoMode(mode);
|
setVideoMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StereoDisplay)
|
|
||||||
StereoDisplay->attachToDisplay();
|
|
||||||
|
|
||||||
// And setup hardware mouse if we have to
|
// And setup hardware mouse if we have to
|
||||||
InitMouseWithCursor (ClientCfg.HardwareCursor);
|
InitMouseWithCursor (ClientCfg.HardwareCursor);
|
||||||
SetMouseFreeLook ();
|
SetMouseFreeLook ();
|
||||||
|
@ -257,8 +258,9 @@ void setOutGameFullScreen()
|
||||||
// NB: don't setup fullscreen if player wants to play in window
|
// NB: don't setup fullscreen if player wants to play in window
|
||||||
if (!ClientCfg.Local && ClientCfg.SelectCharacter == -1)
|
if (!ClientCfg.Local && ClientCfg.SelectCharacter == -1)
|
||||||
{
|
{
|
||||||
if (StereoDisplay)
|
if (StereoDisplayAttached)
|
||||||
StereoDisplay->detachFromDisplay();
|
StereoDisplay->detachFromDisplay();
|
||||||
|
StereoDisplayAttached = false;
|
||||||
|
|
||||||
UDriver::CMode currMode;
|
UDriver::CMode currMode;
|
||||||
Driver->getCurrentScreenMode(currMode);
|
Driver->getCurrentScreenMode(currMode);
|
||||||
|
|
|
@ -28,6 +28,7 @@ using namespace NLMISC;
|
||||||
NL3D::UDriver *Driver = NULL; // The main 3D Driver
|
NL3D::UDriver *Driver = NULL; // The main 3D Driver
|
||||||
NL3D::IStereoDisplay *StereoDisplay = NULL; // Stereo display
|
NL3D::IStereoDisplay *StereoDisplay = NULL; // Stereo display
|
||||||
NL3D::IStereoHMD *StereoHMD = NULL; // Head mount display
|
NL3D::IStereoHMD *StereoHMD = NULL; // Head mount display
|
||||||
|
bool StereoDisplayAttached = false; // Is stereo display handling the display mode
|
||||||
CSoundManager *SoundMngr = NULL; // the sound manager
|
CSoundManager *SoundMngr = NULL; // the sound manager
|
||||||
NL3D::UMaterial GenericMat; // Generic Material
|
NL3D::UMaterial GenericMat; // Generic Material
|
||||||
NL3D::UTextContext *TextContext = NULL; // Context for all the text in the client.
|
NL3D::UTextContext *TextContext = NULL; // Context for all the text in the client.
|
||||||
|
|
|
@ -82,6 +82,7 @@ const float ExtraZoneLoadingVision = 100.f;
|
||||||
extern NL3D::UDriver *Driver; // The main 3D Driver
|
extern NL3D::UDriver *Driver; // The main 3D Driver
|
||||||
extern NL3D::IStereoDisplay *StereoDisplay; // Stereo display
|
extern NL3D::IStereoDisplay *StereoDisplay; // Stereo display
|
||||||
extern NL3D::IStereoHMD *StereoHMD; // Head mount display
|
extern NL3D::IStereoHMD *StereoHMD; // Head mount display
|
||||||
|
extern bool StereoDisplayAttached; // Is stereo display handling the display mode
|
||||||
extern CSoundManager *SoundMngr; // the sound manager
|
extern CSoundManager *SoundMngr; // the sound manager
|
||||||
extern NL3D::UMaterial GenericMat; // Generic Material
|
extern NL3D::UMaterial GenericMat; // Generic Material
|
||||||
extern NL3D::UTextContext *TextContext; // Context for all the text in the client.
|
extern NL3D::UTextContext *TextContext; // Context for all the text in the client.
|
||||||
|
|
|
@ -59,10 +59,20 @@ void updateFromClientCfg()
|
||||||
)))
|
)))
|
||||||
{
|
{
|
||||||
nldebug("Apply VR device change");
|
nldebug("Apply VR device change");
|
||||||
|
// detach display mode
|
||||||
|
if (StereoDisplay && StereoDisplayAttached)
|
||||||
|
StereoDisplay->detachFromDisplay();
|
||||||
|
StereoDisplayAttached = false;
|
||||||
|
// re-init
|
||||||
releaseStereoDisplayDevice();
|
releaseStereoDisplayDevice();
|
||||||
initStereoDisplayDevice();
|
initStereoDisplayDevice();
|
||||||
|
// try attach display mode
|
||||||
if (StereoDisplay)
|
if (StereoDisplay)
|
||||||
StereoDisplay->attachToDisplay();
|
StereoDisplayAttached = StereoDisplay->attachToDisplay();
|
||||||
|
// set latest config display mode if not attached
|
||||||
|
if (!StereoDisplayAttached)
|
||||||
|
setVideoMode(UDriver::CMode(ClientCfg.Width, ClientCfg.Height, (uint8)ClientCfg.Depth,
|
||||||
|
ClientCfg.Windowed, ClientCfg.Frequency));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRAPHICS - GENERAL
|
// GRAPHICS - GENERAL
|
||||||
|
@ -73,7 +83,7 @@ void updateFromClientCfg()
|
||||||
(ClientCfg.Depth != LastClientCfg.Depth) ||
|
(ClientCfg.Depth != LastClientCfg.Depth) ||
|
||||||
(ClientCfg.Frequency != LastClientCfg.Frequency))
|
(ClientCfg.Frequency != LastClientCfg.Frequency))
|
||||||
{
|
{
|
||||||
if (!StereoDisplay) // TODO
|
if (!StereoDisplayAttached)
|
||||||
{
|
{
|
||||||
setVideoMode(UDriver::CMode(ClientCfg.Width, ClientCfg.Height, (uint8)ClientCfg.Depth,
|
setVideoMode(UDriver::CMode(ClientCfg.Width, ClientCfg.Height, (uint8)ClientCfg.Depth,
|
||||||
ClientCfg.Windowed, ClientCfg.Frequency));
|
ClientCfg.Windowed, ClientCfg.Frequency));
|
||||||
|
|
Loading…
Reference in a new issue