From 69fa18c6c055f01696a15f46415e4e2f9186d463 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 26 Jun 2015 18:08:10 -0700 Subject: [PATCH] Working on overlay in plugins --- interface/src/Application.cpp | 55 ++++++++++++---------- interface/src/ui/ApplicationCompositor.cpp | 7 +-- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cdb8864b7c..98db20e6df 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -885,12 +885,10 @@ void Application::paintGL() { { PerformanceTimer perfTimer("renderOverlay"); - /* gpu::Context context(new gpu::GLBackend()); RenderArgs renderArgs(&context, nullptr, getViewFrustum(), lodManager->getOctreeSizeScale(), lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE, RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); - */ _applicationOverlay.renderOverlay(&renderArgs); } @@ -987,6 +985,7 @@ void Application::paintGL() { !Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { renderRearViewMirror(&renderArgs, _mirrorViewRect); } + }, [&] { r.moveLeft(r.width()); }); @@ -1000,6 +999,28 @@ void Application::paintGL() { } } finalFbo = DependencyManager::get()->render(&renderArgs); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); + if (displayPlugin->isStereo()) { + QSize size = DependencyManager::get()->getFrameBufferSize(); + QRect r(QPoint(0, 0), QSize(size.width() / 2, size.height())); + glClear(GL_DEPTH_BUFFER_BIT); + for_each_eye([&](Eye eye) { + glViewport(r.x(), r.y(), r.width(), r.height()); + if (displayPlugin->isHmd()) { + _compositor.displayOverlayTexture(&renderArgs); + } else { + _compositor.displayOverlayTexture(&renderArgs); + } + }, [&] { + r.moveLeft(r.width()); + }); + } else { + glViewport(0, 0, size.width(), size.height()); + _compositor.displayOverlayTexture(&renderArgs); + } + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glFinish(); } #if 0 @@ -1007,39 +1028,23 @@ void Application::paintGL() { if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { renderRearViewMirror(&renderArgs, _mirrorViewRect); } - renderArgs._renderMode = RenderArgs::NORMAL_RENDER_MODE; - - auto finalFbo = DependencyManager::get()->render(&renderArgs); - - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); - glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y, - 0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(), - GL_COLOR_BUFFER_BIT, GL_LINEAR); - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - - _compositor.displayOverlayTexture(&renderArgs); - } -if (!OculusManager::isConnected() || OculusManager::allowSwap()) { - _glWidget->swapBuffers(); -} #endif - // This might not be needed *right now*. We want to ensure that the FBO rendering - // has completed before we start trying to read from it in another context. However - // once we have multi-threaded rendering, this will almost certainly be critical, - // but may be better handled with a fence object + // Ensure the rendering context commands are completed when rendering GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); _offscreenContext->doneCurrent(); Q_ASSERT(!QOpenGLContext::currentContext()); - glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); - glDeleteSync(sync); GLuint finalTexture = gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)); displayPlugin->preDisplay(); + + Q_ASSERT(QOpenGLContext::currentContext()); + glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + glDeleteSync(sync); + displayPlugin->display(finalTexture, finalFbo->getSize()); + displayPlugin->finishFrame(); Q_ASSERT(!QOpenGLContext::currentContext()); _offscreenContext->makeCurrent(); diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index 98da0bfa2f..8c6cdb42b6 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -199,13 +199,14 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) { updateTooltips(); - auto deviceSize = qApp->getDeviceSize(); - glViewport(0, 0, deviceSize.width(), deviceSize.height()); +// auto deviceSize = qApp->getDeviceSize(); +// glViewport(0, 0, deviceSize.width(), deviceSize.height()); + + renderArgs->_context->syncCache(); //Handle fading and deactivation/activation of UI gpu::Batch batch; - renderArgs->_context->syncCache(); auto geometryCache = DependencyManager::get(); geometryCache->useSimpleDrawPipeline(batch);