Fixed issue #925.
This commit is contained in:
parent
449b5b60f0
commit
d6e73b818b
53
src/hmd.cpp
53
src/hmd.cpp
@ -8,26 +8,28 @@
|
|||||||
namespace bgfx
|
namespace bgfx
|
||||||
{
|
{
|
||||||
VR::VR()
|
VR::VR()
|
||||||
: m_framesUntilReconnect(0)
|
: m_impl(NULL)
|
||||||
|
, m_framesUntilReconnect(0)
|
||||||
, m_enabled(false)
|
, m_enabled(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void VR::init(VRImplI* _impl)
|
void VR::init(VRImplI* _impl)
|
||||||
{
|
{
|
||||||
if (!_impl)
|
if (NULL == _impl)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_impl->init())
|
if (!_impl->init() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_impl = _impl;
|
m_impl = _impl;
|
||||||
m_impl->connect(&m_desc);
|
m_impl->connect(&m_desc);
|
||||||
if (!m_impl->isConnected())
|
|
||||||
|
if (!m_impl->isConnected() )
|
||||||
{
|
{
|
||||||
connectFailed();
|
connectFailed();
|
||||||
return;
|
return;
|
||||||
@ -39,13 +41,14 @@ namespace bgfx
|
|||||||
|
|
||||||
void VR::shutdown()
|
void VR::shutdown()
|
||||||
{
|
{
|
||||||
if (!m_impl)
|
if (NULL == m_impl)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_impl->destroySwapChain();
|
m_impl->destroySwapChain();
|
||||||
if (m_impl->isConnected())
|
|
||||||
|
if (m_impl->isConnected() )
|
||||||
{
|
{
|
||||||
m_impl->disconnect();
|
m_impl->disconnect();
|
||||||
}
|
}
|
||||||
@ -69,7 +72,7 @@ namespace bgfx
|
|||||||
|
|
||||||
void VR::recenter()
|
void VR::recenter()
|
||||||
{
|
{
|
||||||
if (m_impl)
|
if (NULL != m_impl)
|
||||||
{
|
{
|
||||||
m_impl->recenter();
|
m_impl->recenter();
|
||||||
}
|
}
|
||||||
@ -77,7 +80,7 @@ namespace bgfx
|
|||||||
|
|
||||||
void VR::preReset()
|
void VR::preReset()
|
||||||
{
|
{
|
||||||
if (m_impl)
|
if (NULL != m_impl)
|
||||||
{
|
{
|
||||||
m_impl->destroyMirror();
|
m_impl->destroyMirror();
|
||||||
}
|
}
|
||||||
@ -87,7 +90,8 @@ namespace bgfx
|
|||||||
|
|
||||||
void VR::postReset(int _msaaSamples, int _mirrorWidth, int _mirrorHeight)
|
void VR::postReset(int _msaaSamples, int _mirrorWidth, int _mirrorHeight)
|
||||||
{
|
{
|
||||||
if (m_impl && m_impl->createSwapChain(m_desc, _msaaSamples, _mirrorWidth, _mirrorHeight))
|
if (NULL != m_impl
|
||||||
|
&& m_impl->createSwapChain(m_desc, _msaaSamples, _mirrorWidth, _mirrorHeight) )
|
||||||
{
|
{
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
}
|
}
|
||||||
@ -95,16 +99,18 @@ namespace bgfx
|
|||||||
|
|
||||||
void VR::flip()
|
void VR::flip()
|
||||||
{
|
{
|
||||||
if (!m_impl || !m_enabled)
|
if (NULL == m_impl
|
||||||
|
|| !m_enabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!m_impl->isConnected() && !tryReconnect())
|
else if (!m_impl->isConnected()
|
||||||
|
&& !tryReconnect() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_impl->submitSwapChain(m_desc))
|
if (!m_impl->submitSwapChain(m_desc) )
|
||||||
{
|
{
|
||||||
m_impl->destroySwapChain();
|
m_impl->destroySwapChain();
|
||||||
m_impl->disconnect();
|
m_impl->disconnect();
|
||||||
@ -116,7 +122,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
_hmd.flags = BGFX_HMD_NONE;
|
_hmd.flags = BGFX_HMD_NONE;
|
||||||
|
|
||||||
if (!m_impl)
|
if (NULL == m_impl)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -127,13 +133,13 @@ namespace bgfx
|
|||||||
_hmd.width = m_hmdSize.m_w;
|
_hmd.width = m_hmdSize.m_w;
|
||||||
_hmd.height = m_hmdSize.m_h;
|
_hmd.height = m_hmdSize.m_h;
|
||||||
|
|
||||||
if (!m_impl->updateTracking(_hmd))
|
if (!m_impl->updateTracking(_hmd) )
|
||||||
{
|
{
|
||||||
m_impl->destroySwapChain();
|
m_impl->destroySwapChain();
|
||||||
m_impl->disconnect();
|
m_impl->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_impl->isConnected())
|
if (!m_impl->isConnected() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -170,7 +176,7 @@ namespace bgfx
|
|||||||
|
|
||||||
m_framesUntilReconnect = 90;
|
m_framesUntilReconnect = 90;
|
||||||
m_impl->connect(&m_desc);
|
m_impl->connect(&m_desc);
|
||||||
if (!m_impl->isConnected())
|
if (!m_impl->isConnected() )
|
||||||
{
|
{
|
||||||
connectFailed();
|
connectFailed();
|
||||||
return false;
|
return false;
|
||||||
@ -186,19 +192,20 @@ namespace bgfx
|
|||||||
// sane defaults
|
// sane defaults
|
||||||
m_desc.m_deviceSize.m_w = 2160;
|
m_desc.m_deviceSize.m_w = 2160;
|
||||||
m_desc.m_deviceSize.m_h = 1200;
|
m_desc.m_deviceSize.m_h = 1200;
|
||||||
m_desc.m_deviceType = 0;
|
m_desc.m_deviceType = 0;
|
||||||
m_desc.m_refreshRate = 90.0f;
|
m_desc.m_refreshRate = 90.0f;
|
||||||
m_desc.m_neckOffset[0] = 0.0805f;
|
m_desc.m_neckOffset[0] = 0.0805f;
|
||||||
m_desc.m_neckOffset[1] = 0.075f;
|
m_desc.m_neckOffset[1] = 0.075f;
|
||||||
|
|
||||||
for (int eye = 0; eye < 2; ++eye)
|
for (int eye = 0; eye < 2; ++eye)
|
||||||
{
|
{
|
||||||
m_desc.m_eyeFov[eye].m_up = 1.32928634f;
|
m_desc.m_eyeFov[eye].m_up = 1.32928634f;
|
||||||
m_desc.m_eyeFov[eye].m_down = 1.32928634f;
|
m_desc.m_eyeFov[eye].m_down = 1.32928634f;
|
||||||
}
|
}
|
||||||
m_desc.m_eyeFov[0].m_left = 1.05865765f;
|
|
||||||
|
m_desc.m_eyeFov[0].m_left = 1.05865765f;
|
||||||
m_desc.m_eyeFov[0].m_right = 1.09236801f;
|
m_desc.m_eyeFov[0].m_right = 1.09236801f;
|
||||||
m_desc.m_eyeFov[1].m_left = 1.09236801f;
|
m_desc.m_eyeFov[1].m_left = 1.09236801f;
|
||||||
m_desc.m_eyeFov[1].m_right = 1.05865765f;
|
m_desc.m_eyeFov[1].m_right = 1.05865765f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ namespace bgfx
|
|||||||
bool tryReconnect();
|
bool tryReconnect();
|
||||||
void connectFailed();
|
void connectFailed();
|
||||||
|
|
||||||
|
VRImplI* m_impl;
|
||||||
VRDesc m_desc;
|
VRDesc m_desc;
|
||||||
VRSize m_hmdSize;
|
VRSize m_hmdSize;
|
||||||
VRImplI* m_impl;
|
|
||||||
uint32_t m_framesUntilReconnect;
|
uint32_t m_framesUntilReconnect;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user