Created
October 7, 2016 19:47
-
-
Save shakesoda/090c2b08ea0affe956d3848b2d6accae to your computer and use it in GitHub Desktop.
bgfx: expose ovrSession as platform data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/include/bgfx/bgfxplatform.h b/include/bgfx/bgfxplatform.h | |
| index f44bb82..497a109 100644 | |
| --- a/include/bgfx/bgfxplatform.h | |
| +++ b/include/bgfx/bgfxplatform.h | |
| @@ -82,6 +82,12 @@ namespace bgfx | |
| /// | |
| const InternalData* getInternalData(); | |
| + struct VRData | |
| + { | |
| + void* session; //!< ovrSession, when using LibOVR. | |
| + }; | |
| + const VRData* getVRData(); | |
| + | |
| /// Override internal texture with externally created texture. Previously | |
| /// created internal texture will released. | |
| /// | |
| diff --git a/src/bgfx.cpp b/src/bgfx.cpp | |
| index e966e1c..9d80023 100644 | |
| --- a/src/bgfx.cpp | |
| +++ b/src/bgfx.cpp | |
| @@ -285,6 +285,7 @@ namespace bgfx | |
| static bool s_renderFrameCalled = false; | |
| InternalData g_internalData; | |
| PlatformData g_platformData; | |
| + VRData g_vrData; | |
| bool g_platformDataChangedSinceReset = false; | |
| void AllocatorStub::checkLeaks() | |
| @@ -321,6 +322,11 @@ namespace bgfx | |
| return &g_internalData; | |
| } | |
| + const VRData* getVRData() | |
| + { | |
| + return &g_vrData; | |
| + } | |
| + | |
| uintptr_t overrideInternal(TextureHandle _handle, uintptr_t _ptr) | |
| { | |
| BGFX_CHECK_RENDER_THREAD(); | |
| diff --git a/src/bgfx_p.h b/src/bgfx_p.h | |
| index 456d81e..3e82dd9 100644 | |
| --- a/src/bgfx_p.h | |
| +++ b/src/bgfx_p.h | |
| @@ -265,6 +265,7 @@ namespace bgfx | |
| { | |
| extern InternalData g_internalData; | |
| extern PlatformData g_platformData; | |
| + extern VRData g_vrData; | |
| extern bool g_platformDataChangedSinceReset; | |
| #if BGFX_CONFIG_MAX_DRAW_CALLS < (64<<10) | |
| diff --git a/src/hmd_ovr.cpp b/src/hmd_ovr.cpp | |
| index 960db03..c7df7b3 100644 | |
| --- a/src/hmd_ovr.cpp | |
| +++ b/src/hmd_ovr.cpp | |
| @@ -60,6 +60,8 @@ namespace bgfx | |
| return; | |
| } | |
| + g_vrData.session = (void*)m_session; | |
| + | |
| BX_STATIC_ASSERT(sizeof(_desc->m_adapterLuid) >= sizeof(luid)); | |
| memcpy(&_desc->m_adapterLuid, &luid, sizeof(luid)); | |
| @@ -121,6 +123,7 @@ namespace bgfx | |
| if (NULL != m_session) | |
| { | |
| ovr_Destroy(m_session); | |
| + g_vrData.session = NULL; | |
| m_session = NULL; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment