History

Revert to using QGLWidget

Brad Davis committed 11 years ago

Commit 382ef051 parent 636407215 files · +305 −244Browse files

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

Unified · Split

interface/src/Application.cpp+28−86
@@ -62,7 +62,6 @@ · 61 unmodified lines
6262 #include <EntityScriptingInterface.h>
6363 #include <ErrorDialog.h>
6464 #include <FramebufferCache.h>
65−#include <GlWindow.h>
6665 #include <gpu/Batch.h>
6766 #include <gpu/Context.h>
6867 #include <gpu/GLBackend.h>
@@ -100,6 +99,7 @@ · 31 unmodified lines
10099
101100 #include "AudioClient.h"
102101 #include "DiscoverabilityManager.h"
102+#include "GLCanvas.h"
103103 #include "InterfaceVersion.h"
104104 #include "LODManager.h"
105105 #include "Menu.h"
@@ -521,25 +521,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 415 unmodified lines
521521
522522 ResourceCache::setRequestLimit(3);
523523
524− _offscreenContext = new OffscreenGlCanvas();
525− _offscreenContext->create();
526− _offscreenContext->makeCurrent();
527−
528− _glWindow = new GlWindow(_offscreenContext->getContext());
524+ _glWidget = new GLCanvas();
525+ _window->setCentralWidget(_glWidget);
529526
530− QWidget* container = QWidget::createWindowContainer(_glWindow);
531− _window->setCentralWidget(container);
532527 _window->restoreGeometry();
533− _window->setVisible(true);
534− _window->setAttribute(Qt::WA_AcceptTouchEvents);
535− container->setFocusPolicy(Qt::StrongFocus);
536− container->setAttribute(Qt::WA_AcceptTouchEvents);
537− container->setFocus();
538− container->installEventFilter(DependencyManager::get<OffscreenUi>().data());
539528
540− _offscreenContext->makeCurrent();
541− initializeGL();
542− // initialization continues in initializeGL when OpenGL context is ready
529+ _glWidget->setFocusPolicy(Qt::StrongFocus);
530+ _glWidget->setFocus();
543531 #ifdef Q_OS_MAC
544532 // OSX doesn't seem to provide for hiding the cursor only on the GL widget
545533 _window->setCursor(Qt::BlankCursor);
@@ -547,11 +535,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 1 unmodified line
547535 // On windows and linux, hiding the top level cursor also means it's invisible
548536 // when hovering over the window menu, which is a pain, so only hide it for
549537 // the GL surface
550− container->setCursor(Qt::BlankCursor);
538+ _glWidget->setCursor(Qt::BlankCursor);
551539 #endif
552540
553541 // enable mouse tracking; otherwise, we only get drag events
554− container->setMouseTracking(true);
542+ _glWidget->setMouseTracking(true);
543+
544+ _offscreenContext = new OffscreenGlCanvas();
545+ _offscreenContext->create(_glWidget->context()->contextHandle());
546+ _offscreenContext->makeCurrent();
547+ initializeGL();
548+
549+ _window->setVisible(true);
550+ _offscreenContext->makeCurrent();
551+
555552
556553 _toolWindow = new ToolWindow();
557554 _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
@@ -858,6 +855,7 @@ void Application::initializeUi() { · 300 unmodified lines
858855 offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
859856 offscreenUi->load("Root.qml");
860857 offscreenUi->load("RootMenu.qml");
858+ _glWidget->installEventFilter(offscreenUi.data());
861859 VrMenu::load();
862860 VrMenu::executeQueuedLambdas();
863861 offscreenUi->setMouseTranslator([=](const QPointF& pt) {
@@ -1284,53 +1282,6 @@ bool Application::eventFilter(QObject* object, QEvent* event) { · 420 unmodified lines
12841282 }
12851283 }
12861284
1287− if (object == _glWindow) {
1288− auto offscreenUi = DependencyManager::get<OffscreenUi>();
1289− if (offscreenUi->eventFilter(object, event)) {
1290− return true;
1291− }
1292− switch (event->type()) {
1293− case QEvent::MouseMove:
1294− mouseMoveEvent((QMouseEvent*)event);
1295− return true;
1296− case QEvent::MouseButtonPress:
1297− mousePressEvent((QMouseEvent*)event);
1298− return true;
1299− case QEvent::MouseButtonDblClick:
1300− mouseDoublePressEvent((QMouseEvent*)event);
1301− return true;
1302− case QEvent::MouseButtonRelease:
1303− mouseReleaseEvent((QMouseEvent*)event);
1304− return true;
1305− case QEvent::KeyPress:
1306− keyPressEvent((QKeyEvent*)event);
1307− return true;
1308− case QEvent::KeyRelease:
1309− keyReleaseEvent((QKeyEvent*)event);
1310− return true;
1311− case QEvent::FocusOut:
1312− focusOutEvent((QFocusEvent*)event);
1313− return true;
1314− case QEvent::TouchBegin:
1315− touchBeginEvent(static_cast<QTouchEvent*>(event));
1316− event->accept();
1317− return true;
1318− case QEvent::TouchEnd:
1319− touchEndEvent(static_cast<QTouchEvent*>(event));
1320− return true;
1321− case QEvent::TouchUpdate:
1322− touchUpdateEvent(static_cast<QTouchEvent*>(event));
1323− return true;
1324− case QEvent::Wheel:
1325− wheelEvent(static_cast<QWheelEvent*>(event));
1326− return true;
1327− case QEvent::Drop:
1328− dropEvent(static_cast<QDropEvent*>(event));
1329− return true;
1330− default:
1331− break;
1332− }
1333− }
13341285 return false;
13351286 }
13361287
@@ -4682,7 +4633,7 @@ void Application::shutdownPlugins() { · 3345 unmodified lines
46824633 }
46834634
46844635 glm::uvec2 Application::getCanvasSize() const {
4685− return toGlm(_glWindow->size());
4636+ return glm::uvec2(_glWidget->width(), _glWidget->height());
46864637 }
46874638
46884639 glm::uvec2 Application::getUiSize() const {
@@ -4702,7 +4653,7 @@ bool Application::isThrottleRendering() const { · 13 unmodified lines
47024653 }
47034654
47044655 ivec2 Application::getTrueMouse() const {
4705− return toGlm(_glWindow->mapFromGlobal(QCursor::pos()));
4656+ return toGlm(_glWidget->mapFromGlobal(QCursor::pos()));
47064657 }
47074658
47084659 bool Application::hasFocus() const {
@@ -4760,11 +4711,6 @@ void Application::updateDisplayMode() { · 51 unmodified lines
47604711 auto offscreenUi = DependencyManager::get<OffscreenUi>();
47614712 DisplayPluginPointer oldDisplayPlugin = _displayPlugin;
47624713 if (oldDisplayPlugin != newDisplayPlugin) {
4763− if (oldDisplayPlugin) {
4764− oldDisplayPlugin->removeEventFilter(qApp);
4765− oldDisplayPlugin->removeEventFilter(offscreenUi.data());
4766− }
4767−
47684714 if (!_currentDisplayPluginActions.isEmpty()) {
47694715 auto menu = Menu::getInstance();
47704716 foreach(auto itemInfo, _currentDisplayPluginActions) {
@@ -4776,16 +4722,7 @@ void Application::updateDisplayMode() { · 5 unmodified lines
47764722 if (newDisplayPlugin) {
47774723 _offscreenContext->makeCurrent();
47784724 newDisplayPlugin->activate(this);
4779−
47804725 _offscreenContext->makeCurrent();
4781− newDisplayPlugin->installEventFilter(qApp);
4782− newDisplayPlugin->installEventFilter(offscreenUi.data());
4783− QWindow* pluginWindow = newDisplayPlugin->getWindow();
4784− if (pluginWindow) {
4785− DependencyManager::get<OffscreenUi>()->setProxyWindow(pluginWindow);
4786− } else {
4787− DependencyManager::get<OffscreenUi>()->setProxyWindow(nullptr);
4788− }
47894726 offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize()));
47904727 _offscreenContext->makeCurrent();
47914728 }
@@ -4882,10 +4819,6 @@ void Application::setIsOptionChecked(const QString& path, bool checked) { · 90 unmodified lines
48824819 Menu::getInstance()->setIsOptionChecked(path, checked);
48834820 }
48844821
4885−GlWindow* Application::getVisibleWindow() {
4886− return _glWindow;
4887−}
4888−
48894822 mat4 Application::getEyeProjection(int eye) const {
48904823 if (isHMDMode()) {
48914824 return getActiveDisplayPlugin()->getProjection((Eye)eye, _viewFrustum.getProjection());
@@ -4941,3 +4874,12 @@ void Application::unsetFullscreen() { · 49 unmodified lines
49414874 _window->setGeometry(_savedGeometry);
49424875 #endif
49434876 }
4877+
4878+
4879+void Application::showDisplayPluginsTools() {
4880+
4881+}
4882+
4883+QGLWidget* Application::getPrimarySurface() {
4884+ return _glWidget;
4885+}