MCPcopy Create free account
hub / github.com/LibreVR/Revive / OnSceneChanged

Method OnSceneChanged

ReviveOverlay/openvroverlaycontroller.cpp:220–256  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Purpose: -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

218// Purpose:
219//-----------------------------------------------------------------------------
220void COpenVROverlayController::OnSceneChanged()
221{
222 // skip rendering if the overlay and window aren't visible
223 const bool overlayVisible = vr::VROverlay() && (vr::VROverlay()->IsOverlayVisible(m_ulOverlayHandle) || vr::VROverlay()->IsOverlayVisible(m_ulOverlayThumbnailHandle));
224 if(!overlayVisible && !m_pWindow->isVisible())
225 return;
226
227 if (!m_pOpenGLContext->makeCurrent(m_pOffscreenSurface))
228 return;
229
230 // Polish, synchronize and render the next frame (into our fbo). In this example
231 // everything happens on the same thread and therefore all three steps are performed
232 // in succession from here. In a threaded setup the render() call would happen on a
233 // separate thread.
234 m_pRenderControl->polishItems();
235 m_pRenderControl->sync();
236 m_pRenderControl->render();
237
238 m_pWindow->resetOpenGLState();
239 QOpenGLFramebufferObject::bindDefault();
240
241 m_pOpenGLContext->functions()->glFlush();
242 uintptr_t unTexture = m_pFbo->texture();
243 if( vr::VROverlay() && unTexture != 0 )
244 {
245 vr::Texture_t texture = {(void*)unTexture, vr::TextureType_OpenGL, vr::ColorSpace_Auto };
246 vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &texture );
247 }
248
249 if (!m_pOpenGLContext->makeCurrent(m_pWindow))
250 return;
251
252 QRect target(QPoint(), m_pWindow->size());
253 QRect source(QPoint(), m_pWindow->renderTargetSize());
254 QOpenGLFramebufferObject::blitFramebuffer(nullptr, target, m_pFbo, source, GL_COLOR_BUFFER_BIT, GL_LINEAR);
255 m_pOpenGLContext->swapBuffers(m_pWindow);
256}
257
258
259//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected