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