diff options
Diffstat (limited to '3rdparty/bgfx/src/hmd_ovr.h')
-rw-r--r-- | 3rdparty/bgfx/src/hmd_ovr.h | 169 |
1 files changed, 27 insertions, 142 deletions
diff --git a/3rdparty/bgfx/src/hmd_ovr.h b/3rdparty/bgfx/src/hmd_ovr.h index 675e711c01e..a2a2d34a63b 100644 --- a/3rdparty/bgfx/src/hmd_ovr.h +++ b/3rdparty/bgfx/src/hmd_ovr.h @@ -10,6 +10,7 @@ #if BGFX_CONFIG_USE_OVR +# include "hmd.h" # include <OVR_Version.h> # define OVR_VERSION_(_a, _b, _c) (_a * 10000 + _b * 100 + _c) @@ -25,157 +26,41 @@ # include <OVR_CAPI_GL.h> # endif // BGFX_CONFIG_RENDERER_OPENGL -namespace bgfx -{ - // single eye buffer - struct OVRBufferI - { - virtual ~OVRBufferI() {}; - virtual void create(const ovrSession& _session, int _eyeIdx, int _msaaSamples) = 0; - virtual void destroy(const ovrSession& _session) = 0; - virtual void render(const ovrSession& _session) = 0; - virtual void postRender(const ovrSession& _session) = 0; - ovrSizei m_eyeTextureSize; - ovrTextureSwapChain m_textureSwapChain; - }; - - // mirrored window output - struct OVRMirrorI - { - virtual ~OVRMirrorI() {}; - virtual void create(const ovrSession& _session, int windowWidth, int windowHeight) = 0; - virtual void destroy(const ovrSession& _session) = 0; - virtual void blit(const ovrSession& _session) = 0; - - ovrMirrorTexture m_mirrorTexture; - ovrMirrorTextureDesc m_mirrorTextureDesc; - }; - - struct OVR - { - enum Enum - { - NotEnabled, - DeviceLost, - Success, - - Count - }; - - OVR(); - ~OVR(); - - bool isInitialized() const - { - return NULL != m_hmd; - } - - bool isEnabled() const - { - return m_enabled; - } - - void init(); - void shutdown(); - - void getViewport(uint8_t _eye, Rect* _viewport); - void renderEyeStart(uint8_t _eye); - bool postReset(); - void preReset(); - Enum swap(HMD& _hmd, bool originBottomLeft); - void recenter(); - void getEyePose(HMD& _hmd); - - ovrSession m_hmd; - ovrHmdDesc m_hmdDesc; - ovrEyeRenderDesc m_erd[2]; - ovrRecti m_rect[2]; - ovrPosef m_pose[2]; - ovrVector3f m_hmdToEyeOffset[2]; - ovrSizei m_hmdSize; - OVRBufferI *m_eyeBuffers[2]; - OVRMirrorI *m_mirror; - uint64_t m_frameIndex; - double m_sensorSampleTime; - bool m_enabled; - }; - -} // namespace bgfx - -#else namespace bgfx { - struct OVR + class VRImplOVR : public VRImplI { - enum Enum - { - NotEnabled, - DeviceLost, - Success, + public: + VRImplOVR(); + virtual ~VRImplOVR() = 0; - Count - }; + virtual bool init() BX_OVERRIDE; + virtual void shutdown() BX_OVERRIDE; + virtual void connect(VRDesc* _desc) BX_OVERRIDE; + virtual void disconnect() BX_OVERRIDE; - OVR() + virtual bool isConnected() const BX_OVERRIDE { + return NULL != m_session; } - ~OVR() - { - } - - bool isInitialized() const - { - return false; - } - - bool isEnabled() const - { - return false; - } - - bool isDebug() const - { - return false; - } - - void init() - { - } - - void shutdown() - { - } - - void getViewport(uint8_t /*_eye*/, Rect* _viewport) - { - _viewport->m_x = 0; - _viewport->m_y = 0; - _viewport->m_width = 0; - _viewport->m_height = 0; - } - - void renderEyeStart(uint8_t /*_eye*/) - { - } - - Enum swap(HMD& _hmd, bool /*originBottomLeft*/) - { - _hmd.flags = BGFX_HMD_NONE; - getEyePose(_hmd); - return NotEnabled; - } - - void recenter() - { - } - - void getEyePose(HMD& _hmd) - { - _hmd.width = 0; - _hmd.height = 0; - } + virtual bool updateTracking(HMD& _hmd) BX_OVERRIDE; + virtual void updateInput(HMD& _hmd) BX_OVERRIDE; + virtual void recenter() BX_OVERRIDE; + + virtual bool createSwapChain(const VRDesc& _desc, int _msaaSamples, int _mirrorWidth, int _mirrorHeight) BX_OVERRIDE = 0; + virtual void destroySwapChain() BX_OVERRIDE = 0; + virtual void destroyMirror() BX_OVERRIDE = 0; + virtual void renderEyeStart(const VRDesc& _desc, uint8_t _eye) BX_OVERRIDE = 0; + virtual bool submitSwapChain(const VRDesc& _desc) BX_OVERRIDE = 0; + + protected: + ovrSession m_session; + ovrLayerEyeFov m_renderLayer; + ovrViewScaleDesc m_viewScale; + ovrFovPort m_eyeFov[2]; + ovrVector2f m_pixelsPerTanAngleAtCenter[2]; }; } // namespace bgfx |