History

Working on merging in master

Brad Davis committed 11 years ago

Commit ba4ae371 parent 031b29414 files · +111 −119Browse files

Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all

Unified · Split

interface/src/Application.cpp+20−80
@@ -114,6 +114,8 @@ · 113 unmodified lines
114114 #include "gpu/Batch.h"
115115 #include "gpu/GLBackend.h"
116116
117+#include "plugins/render/RenderPlugin.h"
118+
117119 #include "scripting/AccountScriptingInterface.h"
118120 #include "scripting/AudioDeviceScriptingInterface.h"
119121 #include "scripting/ClipboardScriptingInterface.h"
@@ -584,7 +586,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 464 unmodified lines
584586 this->installEventFilter(this);
585587 // The offscreen UI needs to intercept the mouse and keyboard
586588 // events coming from the onscreen window
587− _glWidget->installEventFilter(DependencyManager::get<OffscreenUi>().data());
589+ //_glWidget->installEventFilter(DependencyManager::get<OffscreenUi>().data());
588590 }
589591
590592
@@ -726,7 +728,7 @@ void Application::initializeGL() { · 135 unmodified lines
726728 // texture resources
727729 initializeUi();
728730 qCDebug(interfaceapp, "Initialized Offscreen UI.");
729− _glWidget->makeCurrent();
731+ _offscreenContext->makeCurrent();
730732
731733 // call Menu getInstance static method to set up the menu
732734 // Needs to happen AFTER the QML UI initialization
@@ -770,30 +772,24 @@ void Application::initializeUi() { · 37 unmodified lines
770772 VrMenu::registerType();
771773
772774 auto offscreenUi = DependencyManager::get<OffscreenUi>();
773− offscreenUi->create(_glWidget->context()->contextHandle());
774− offscreenUi->resize(_glWidget->size());
775+ offscreenUi->create(_offscreenContext->getContext());
776+ offscreenUi->resize(fromGlm(getActiveRenderPlugin()->getCanvasSize()));
775777 offscreenUi->setProxyWindow(_window->windowHandle());
776778 offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
777779 offscreenUi->load("Root.qml");
778780 offscreenUi->load("RootMenu.qml");
779781 VrMenu::load();
780782 VrMenu::executeQueuedLambdas();
781− offscreenUi->setMouseTranslator([this](const QPointF& p){
782− if (OculusManager::isConnected()) {
783− glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p));
784− return QPointF(pos.x, pos.y);
785− }
786− return QPointF(p);
787− });
783+ offscreenUi->setMouseTranslator(getActiveRenderPlugin()->getMouseTranslator());
788784 offscreenUi->resume();
789785 connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect & r){
790786 static qreal oldDevicePixelRatio = 0;
791− qreal devicePixelRatio = _glWidget->devicePixelRatio();
787+ qreal devicePixelRatio = getActiveRenderPlugin()->devicePixelRatio();
792788 if (devicePixelRatio != oldDevicePixelRatio) {
793789 oldDevicePixelRatio = devicePixelRatio;
794790 qDebug() << "Device pixel ratio changed, triggering GL resize";
795− resizeGL(_glWidget->width(),
796− _glWidget->height());
791+ auto canvasSize = getActiveRenderPlugin()->getCanvasSize();
792+ resizeGL(canvasSize.x, canvasSize.y);
797793 }
798794 });
799795 }
@@ -846,8 +842,9 @@ void Application::paintGL() { · 46 unmodified lines
846842 DependencyManager::get<GlowEffect>()->prepare();
847843
848844 // Primary rendering pass
849− auto primaryFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject();
850− primaryFbo->bind();
845+ auto primaryFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
846+ auto finalFbo = primaryFbo;
847+ glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
851848 {
852849 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
853850
@@ -864,32 +861,18 @@ void Application::paintGL() { · 10 unmodified lines
864861 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
865862 _rearMirrorTools->render(true);
866863 } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
867−<<<<<<< HEAD
868864 renderRearViewMirror(_mirrorViewRect);
869−=======
870− renderRearViewMirror(_mirrorViewRect);
871865 }
872866
873− DependencyManager::get<GlowEffect>()->render();
874−
867+ finalFbo = DependencyManager::get<GlowEffect>()->render();
875868 {
876869 PerformanceTimer perfTimer("renderOverlay");
877870 _applicationOverlay.renderOverlay();
871+ glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
878872 _applicationOverlay.displayOverlayTexture();
879−>>>>>>> master
873+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
880874 }
881875 }
882− primaryFbo->release();
883−
884− QOpenGLFramebufferObject * finalFbo = DependencyManager::get<GlowEffect>()->render();
885−
886− finalFbo->bind();
887− {
888− PerformanceTimer perfTimer("renderOverlay");
889− _applicationOverlay.renderOverlay();
890− _applicationOverlay.displayOverlayTexture();
891− }
892− finalFbo->release();
893876
894877 // This might not be needed *right now*. We want to ensure that the FBO rendering
895878 // has completed before we start trying to read from it in another context. However
@@ -899,7 +882,7 @@ void Application::paintGL() { · 3 unmodified lines
899882
900883 _offscreenContext->doneCurrent();
901884 Q_ASSERT(!QOpenGLContext::currentContext());
902− getActiveRenderPlugin()->render(finalFbo->texture());
885+ getActiveRenderPlugin()->render(gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)));
903886 Q_ASSERT(!QOpenGLContext::currentContext());
904887 _offscreenContext->makeCurrent();
905888 _frameCount++;
@@ -951,8 +934,9 @@ void Application::resizeGL(int width, int height) { · 45 unmodified lines
951934 updateProjectionMatrix();
952935 glLoadIdentity();
953936
937+ auto canvasSize = getActiveRenderPlugin()->getCanvasSize();
954938 auto offscreenUi = DependencyManager::get<OffscreenUi>();
955− offscreenUi->resize(_glWidget->size());
939+ offscreenUi->resize(fromGlm(canvasSize));
956940
957941 // update Stats width
958942 // let's set horizontal offset to give stats some margin to mirror
@@ -1003,43 +987,6 @@ bool Application::importSVOFromURL(const QString& urlString) { · 44 unmodified lines
1003987
1004988 bool Application::event(QEvent* event) {
1005989 switch (event->type()) {
1006−<<<<<<< HEAD
1007− case QEvent::MouseMove:
1008− mouseMoveEvent((QMouseEvent*)event);
1009− return true;
1010−
1011− case QEvent::MouseButtonPress:
1012− mousePressEvent((QMouseEvent*)event);
1013− return true;
1014−
1015− case QEvent::MouseButtonRelease:
1016− mouseReleaseEvent((QMouseEvent*)event);
1017− return true;
1018−
1019− case QEvent::KeyPress:
1020− keyPressEvent((QKeyEvent*)event);
1021− return true;
1022−
1023− case QEvent::KeyRelease:
1024− keyReleaseEvent((QKeyEvent*)event);
1025− return true;
1026−
1027− case QEvent::FocusIn:
1028− //focusInEvent((QFocusEvent*)event);
1029− //return true;
1030− break;
1031−
1032− case QEvent::FocusOut:
1033− focusOutEvent((QFocusEvent*)event);
1034− return true;
1035−
1036− case QEvent::Resize:
1037− resizeEvent((QResizeEvent *)event);
1038− return true;
1039−
1040− default:
1041− break;
1042−=======
1043990 case Lambda:
1044991 ((LambdaEvent*)event)->call();
1045992 return true;
@@ -1080,7 +1027,6 @@ bool Application::event(QEvent* event) { · 34 unmodified lines
10801027 return true;
10811028 default:
10821029 break;
1083−>>>>>>> master
10841030 }
10851031
10861032 // handle custom URL
@@ -2990,13 +2936,7 @@ void Application::updateShadowMap() { · 1903 unmodified lines
29902936 glMatrixMode(GL_MODELVIEW);
29912937 }
29922938
2993−<<<<<<< HEAD
2994− fbo->release();
2995−=======
2996− // fbo->release();
2997−
2998− glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
2999−>>>>>>> master
2939+// glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
30002940 activeRenderingThread = nullptr;
30012941 }
30022942