Merge pull request #423 from mendsley/vr_viewportfix
VR: Fix skewed viewports with buffered eye textures
This commit is contained in:
commit
d2204e5cf2
@ -69,6 +69,14 @@ namespace bgfx
|
|||||||
ovr_Shutdown();
|
ovr_Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OVR::getViewport(uint8_t _eye, Rect* _viewport)
|
||||||
|
{
|
||||||
|
_viewport->m_width = (m_rtSize.w - s_eyeBuffer)/2;
|
||||||
|
_viewport->m_height = m_rtSize.h;
|
||||||
|
_viewport->m_x = _eye * (m_rtSize.w + s_eyeBuffer + 1)/2;
|
||||||
|
_viewport->m_y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool OVR::postReset(void* _nwh, ovrRenderAPIConfig* _config, bool _debug)
|
bool OVR::postReset(void* _nwh, ovrRenderAPIConfig* _config, bool _debug)
|
||||||
{
|
{
|
||||||
if (_debug)
|
if (_debug)
|
||||||
|
@ -67,6 +67,7 @@ namespace bgfx
|
|||||||
void init();
|
void init();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
void getViewport(uint8_t _eye, Rect* _viewport);
|
||||||
bool postReset(void* _nwh, ovrRenderAPIConfig* _config, bool _debug = false);
|
bool postReset(void* _nwh, ovrRenderAPIConfig* _config, bool _debug = false);
|
||||||
void postReset(const ovrTexture& _texture);
|
void postReset(const ovrTexture& _texture);
|
||||||
void preReset();
|
void preReset();
|
||||||
|
@ -3856,9 +3856,18 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||||||
PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW);
|
PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), viewNameW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BGFX_CONFIG_USE_OVR
|
||||||
|
if (m_ovr.isEnabled())
|
||||||
|
{
|
||||||
|
m_ovr.getViewport(eye, &viewState.m_rect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // BGFX_CONFIG_USE_OVR
|
||||||
|
{
|
||||||
viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2;
|
viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2;
|
||||||
viewState.m_rect.m_width /= 2;
|
viewState.m_rect.m_width /= 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
|
||||||
|
@ -4963,9 +4963,18 @@ namespace bgfx { namespace gl
|
|||||||
GL_CHECK(glInsertEventMarker(0, viewName) );
|
GL_CHECK(glInsertEventMarker(0, viewName) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BGFX_CONFIG_USE_OVR
|
||||||
|
if (m_ovr.isEnabled())
|
||||||
|
{
|
||||||
|
m_ovr.getViewport(eye, &viewState.m_rect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // BGFX_CONFIG_USE_OVR
|
||||||
|
{
|
||||||
viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2;
|
viewState.m_rect.m_x = eye * (viewState.m_rect.m_width+1)/2;
|
||||||
viewState.m_rect.m_width /= 2;
|
viewState.m_rect.m_width /= 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
|
||||||
|
Loading…
Reference in New Issue
Block a user