From 58fae3687006311685cb066007f2131da572e8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 4 Jun 2015 18:26:09 -0700 Subject: [PATCH 1/3] input: Added ability to retrieve modifiers state. --- examples/common/entry/input.cpp | 15 +++++++++++++++ examples/common/entry/input.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index 2f6933fd..a0618f86 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -109,6 +109,16 @@ struct Keyboard return decodeKeyState(m_key[_key], *_modifiers); } + uint8_t getModifiersState() + { + uint8_t modifiers = 0; + for (uint32_t ii = 0; ii < entry::Key::Count; ++ii) + { + modifiers |= (m_key[ii]>>16)&0xff; + } + return modifiers; + } + void pushChar(uint8_t _len, const uint8_t _char[4]) { for (uint32_t len = m_ring.reserve(4) @@ -314,6 +324,11 @@ bool inputGetKeyState(entry::Key::Enum _key, uint8_t* _modifiers) return s_input->m_keyboard.getKeyState(_key, _modifiers); } +uint8_t inputGetModifiersState() +{ + return s_input->m_keyboard.getModifiersState(); +} + void inputChar(uint8_t _len, const uint8_t _char[4]) { s_input->m_keyboard.pushChar(_len, _char); diff --git a/examples/common/entry/input.h b/examples/common/entry/input.h index f18b899b..2dcbbdb7 100644 --- a/examples/common/entry/input.h +++ b/examples/common/entry/input.h @@ -42,6 +42,9 @@ void inputSetKeyState(entry::Key::Enum _key, uint8_t _modifiers, bool _down); /// bool inputGetKeyState(entry::Key::Enum _key, uint8_t* _modifiers = NULL); +/// +uint8_t inputGetModifiersState(); + /// Adds single UTF-8 encoded character into input buffer. void inputChar(uint8_t _len, const uint8_t _char[4]); From acdaefb1616d14db3bc9d866572434b96ee39542 Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Thu, 4 Jun 2015 18:38:11 -0700 Subject: [PATCH 2/3] VR: Fix OVR_VERSION macro. Was previously supplying (major,minor,build) when it is actuall (product,major,minor). For example, the 0.5.0 SDK has the following: ``` #define OVR_PRODUCT_VERSION 0 #define OVR_MAJOR_VERSION 5 #define OVR_MINOR_VERSION 0 #define OVR_PATCH_VERSION 1 #define OVR_BUILD_NUMBER 0 ``` --- src/ovr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ovr.h b/src/ovr.h index 6fe1c188..58fd9ec3 100644 --- a/src/ovr.h +++ b/src/ovr.h @@ -13,7 +13,7 @@ # include # define OVR_VERSION_(_a, _b, _c) (_a * 10000 + _b * 100 + _c) -# define OVR_VERSION OVR_VERSION_(OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_BUILD_VERSION) +# define OVR_VERSION OVR_VERSION_(OVR_PRODUCT_VERSION, OVR_MAJOR_VERSION, OVR_MINOR_VERSION) # define OVR_VERSION_042 OVR_VERSION_(0, 4, 2) # define OVR_VERSION_043 OVR_VERSION_(0, 4, 3) # define OVR_VERSION_044 OVR_VERSION_(0, 4, 4) From 9020994470c73688e02581d7df10d1ad2332efe9 Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Thu, 4 Jun 2015 18:08:08 -0700 Subject: [PATCH 3/3] VR: Add buffer between left/right eye textures This prevents bleeding across the individual viewports when the oculus SDK applies distortion mapping. The current reccommended values are 100px for SDK <= 0.5 and 8px for > 0.5 See: http://static.oculus.com/sdk-downloads/documents/0.6.0/Oculus_Developer_Guide.pdf in the "Bugs Fixed Since the Last Release" section. For an example of this artifact, see the correct scene render: ![Imgur](http://i.imgur.com/fZZExg8.jpg) followed by a scene that bleeds the left eye into the right eye: ![Imgur](http://i.imgur.com/dZalmPS.jpg) --- src/ovr.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ovr.cpp b/src/ovr.cpp index 493c8dfc..169e1004 100644 --- a/src/ovr.cpp +++ b/src/ovr.cpp @@ -9,6 +9,12 @@ namespace bgfx { +#if OVR_VERSION <= OVR_VERSION_050 + static const int s_eyeBuffer = 100; +#else + static const int s_eyeBuffer = 8; +#endif // OVR_VERSION... + OVR::OVR() : m_hmd(NULL) , m_isenabled(false) @@ -50,7 +56,7 @@ namespace bgfx ovrSizei sizeL = ovrHmd_GetFovTextureSize(m_hmd, ovrEye_Left, m_hmd->DefaultEyeFov[0], 1.0f); ovrSizei sizeR = ovrHmd_GetFovTextureSize(m_hmd, ovrEye_Right, m_hmd->DefaultEyeFov[1], 1.0f); - m_rtSize.w = sizeL.w + sizeR.w; + m_rtSize.w = sizeL.w + sizeR.w + s_eyeBuffer; m_rtSize.h = bx::uint32_max(sizeL.h, sizeR.h); m_warning = true; } @@ -169,12 +175,12 @@ ovrError: ovrRecti rect; rect.Pos.x = 0; rect.Pos.y = 0; - rect.Size.w = m_rtSize.w/2; + rect.Size.w = (m_rtSize.w - s_eyeBuffer)/2; rect.Size.h = m_rtSize.h; m_texture[0].Header.RenderViewport = rect; - rect.Pos.x += rect.Size.w; + rect.Pos.x += rect.Size.w + s_eyeBuffer; m_texture[1].Header.RenderViewport = rect; m_timing = ovrHmd_BeginFrame(m_hmd, 0);