Convert m_pOpenGLContext from pointer to object

This commit is contained in:
Vasily
2019-11-30 18:14:49 +01:00
committed by username223
parent 6c04dd25b1
commit 8136569455
2 changed files with 8 additions and 10 deletions
+7 -9
View File
@@ -111,18 +111,17 @@ OverlayController::OverlayController( bool desktopMode,
format.setStencilBufferSize( 8 ); format.setStencilBufferSize( 8 );
format.setSamples( 16 ); format.setSamples( 16 );
m_pOpenGLContext.reset( new QOpenGLContext() ); m_openGLContext.setFormat( format );
m_pOpenGLContext->setFormat( format ); if ( !m_openGLContext.create() )
if ( !m_pOpenGLContext->create() )
{ {
throw std::runtime_error( "Could not create OpenGL context" ); throw std::runtime_error( "Could not create OpenGL context" );
} }
// create an offscreen surface to attach the context and FBO to // create an offscreen surface to attach the context and FBO to
m_pOffscreenSurface.reset( new QOffscreenSurface() ); m_pOffscreenSurface.reset( new QOffscreenSurface() );
m_pOffscreenSurface->setFormat( m_pOpenGLContext->format() ); m_pOffscreenSurface->setFormat( m_openGLContext.format() );
m_pOffscreenSurface->create(); m_pOffscreenSurface->create();
m_pOpenGLContext->makeCurrent( m_pOffscreenSurface.get() ); m_openGLContext.makeCurrent( m_pOffscreenSurface.get() );
if ( !vr::VROverlay() ) if ( !vr::VROverlay() )
{ {
@@ -418,7 +417,6 @@ void OverlayController::Shutdown()
m_pRenderTimer.reset(); m_pRenderTimer.reset();
} }
m_pFbo.reset(); m_pFbo.reset();
m_pOpenGLContext.reset();
m_pOffscreenSurface.reset(); m_pOffscreenSurface.reset();
// save to settings that shutdown was safe // save to settings that shutdown was safe
@@ -497,7 +495,7 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
0, 0,
static_cast<int>( quickItem->width() ), static_cast<int>( quickItem->width() ),
static_cast<int>( quickItem->height() ) ); static_cast<int>( quickItem->height() ) );
m_renderControl.initialize( m_pOpenGLContext.get() ); m_renderControl.initialize( &m_openGLContext );
vr::HmdVector2_t vecWindowSize vr::HmdVector2_t vecWindowSize
= { static_cast<float>( quickItem->width() ), = { static_cast<float>( quickItem->width() ),
@@ -575,8 +573,8 @@ void OverlayController::renderOverlay()
#endif #endif
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &texture ); vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &texture );
} }
m_pOpenGLContext->functions()->glFlush(); // We need to flush otherwise m_openGLContext.functions()->glFlush(); // We need to flush otherwise
// the texture may be empty.*/ // the texture may be empty.*/
} }
} }
+1 -1
View File
@@ -109,7 +109,7 @@ private:
QQuickRenderControl m_renderControl; QQuickRenderControl m_renderControl;
QQuickWindow m_window{ &m_renderControl }; QQuickWindow m_window{ &m_renderControl };
std::unique_ptr<QOpenGLFramebufferObject> m_pFbo; std::unique_ptr<QOpenGLFramebufferObject> m_pFbo;
std::unique_ptr<QOpenGLContext> m_pOpenGLContext; QOpenGLContext m_openGLContext;
std::unique_ptr<QOffscreenSurface> m_pOffscreenSurface; std::unique_ptr<QOffscreenSurface> m_pOffscreenSurface;
std::unique_ptr<QTimer> m_pPumpEventsTimer; std::unique_ptr<QTimer> m_pPumpEventsTimer;