From 7258a22cf71a36f5357445df7aad3cd8f7d25675 Mon Sep 17 00:00:00 2001 From: Eric Renaud-Houde Date: Mon, 10 Apr 2017 11:02:24 -0400 Subject: [PATCH 1/3] Removed frame index, not needed. --- include/cinder/vr/oculus/Hmd.h | 2 -- src/cinder/vr/oculus/Hmd.cpp | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/cinder/vr/oculus/Hmd.h b/include/cinder/vr/oculus/Hmd.h index 37b1534..9c30057 100644 --- a/include/cinder/vr/oculus/Hmd.h +++ b/include/cinder/vr/oculus/Hmd.h @@ -101,7 +101,6 @@ class Hmd : public vr::Hmd { glm::ivec2 getNativeResolution() const { return fromOvr( mHmdDesc.Resolution ); } glm::ivec2 getRenderTargetSize() const { return mRenderTargetSize; } - protected: // --------------------------------------------------------------------------------------------- // Protected methods inherited from ci::vr::Hmd @@ -127,7 +126,6 @@ class Hmd : public vr::Hmd { bool mIsVisible = true; // Oculus SDK - long long mFrameIndex = 0; ::ovrSession mSession = nullptr; ::ovrHmdDesc mHmdDesc; diff --git a/src/cinder/vr/oculus/Hmd.cpp b/src/cinder/vr/oculus/Hmd.cpp index e84a4e3..a9ad53a 100644 --- a/src/cinder/vr/oculus/Hmd.cpp +++ b/src/cinder/vr/oculus/Hmd.cpp @@ -275,7 +275,7 @@ void Hmd::bind() // Calculate input ray calculateInputRay(); - ::ovr_GetEyePoses( mSession, mFrameIndex, ovrTrue, mEyeViewOffset, mEyeRenderPose, &mSensorSampleTime ); + ::ovr_GetEyePoses( mSession, 0, ovrTrue, mEyeViewOffset, mEyeRenderPose, &mSensorSampleTime ); const ::ovrEyeType kEyes[2] = { ::ovrEye_Left, ::ovrEye_Right }; for( auto eye : kEyes ) { // View matrix @@ -342,11 +342,9 @@ void Hmd::submitFrame() mBaseLayer.ColorTexture[1] = NULL; ovrLayerHeader* layers = &mBaseLayer.Header; - auto result = ::ovr_SubmitFrame( mSession, mFrameIndex, &viewScaleDesc, &layers, 1 ); + auto result = ::ovr_SubmitFrame( mSession, 0, &viewScaleDesc, &layers, 1 ); mIsVisible = ( result == ovrSuccess ); - ++mFrameIndex; - // Update frame index if( mIsVisible ) { updateElapsedFrames(); From 0046aa9c4d4e589038ad866a3f49d83dd7636b89 Mon Sep 17 00:00:00 2001 From: Eric Renaud-Houde Date: Mon, 10 Apr 2017 11:03:07 -0400 Subject: [PATCH 2/3] Catch resize hmd exception throw, causing crash on minimizing window. --- src/cinder/vr/oculus/Hmd.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cinder/vr/oculus/Hmd.cpp b/src/cinder/vr/oculus/Hmd.cpp index a9ad53a..2e34db5 100644 --- a/src/cinder/vr/oculus/Hmd.cpp +++ b/src/cinder/vr/oculus/Hmd.cpp @@ -70,7 +70,12 @@ Hmd::Hmd( ci::vr::oculus::Context *context ) initializeRenderTarget(); onMonoscopicChange(); app::getWindow()->getSignalResize().connect( [this](){ - initializeMirrorTexture( app::getWindowSize() ); + try { + initializeMirrorTexture( app::getWindowSize() ); + } + catch( ci::vr::oculus::Exception& exc ) { + CI_LOG_EXCEPTION( exc.what(), exc ); + } } ); //ovr_SetTrackingOriginType( mSession, ovrTrackingOrigin_EyeLevel ); From 60acf9a43ca203a220fb98bb4c8004343e3f625a Mon Sep 17 00:00:00 2001 From: Eric Renaud-Houde Date: Mon, 10 Apr 2017 11:03:37 -0400 Subject: [PATCH 3/3] Fixed SRGB mirror texture color problem. --- src/cinder/vr/oculus/Hmd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cinder/vr/oculus/Hmd.cpp b/src/cinder/vr/oculus/Hmd.cpp index 2e34db5..793cf2d 100644 --- a/src/cinder/vr/oculus/Hmd.cpp +++ b/src/cinder/vr/oculus/Hmd.cpp @@ -462,6 +462,7 @@ void Hmd::calculateInputRay() void Hmd::drawMirroredImpl( const ci::Rectf& r ) { if( isMirrored() && mMirrorTexture ) { + gl::enable( GL_FRAMEBUFFER_SRGB ); ci::gl::ScopedDepth scopedDepth( false ); ci::gl::ScopedColor scopedColor( 1, 1, 1 ); ci::gl::ScopedModelMatrix scopedModelMatrix; @@ -503,6 +504,7 @@ void Hmd::drawMirroredImpl( const ci::Rectf& r ) } break; } + gl::disable( GL_FRAMEBUFFER_SRGB ); } }