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
62#include <EntityScriptingInterface.h>62#include <EntityScriptingInterface.h>
63#include <ErrorDialog.h>63#include <ErrorDialog.h>
64#include <FramebufferCache.h>64#include <FramebufferCache.h>
65#include <GlWindow.h>
66#include <gpu/Batch.h>65#include <gpu/Batch.h>
67#include <gpu/Context.h>66#include <gpu/Context.h>
68#include <gpu/GLBackend.h>67#include <gpu/GLBackend.h>
@@ -100,6 +99,7 @@ · 31 unmodified lines
100 99
101#include "AudioClient.h"100#include "AudioClient.h"
102#include "DiscoverabilityManager.h"101#include "DiscoverabilityManager.h"
102#include "GLCanvas.h"
103#include "InterfaceVersion.h"103#include "InterfaceVersion.h"
104#include "LODManager.h"104#include "LODManager.h"
105#include "Menu.h"105#include "Menu.h"
@@ -521,25 +521,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 415 unmodified lines
521 521
522 ResourceCache::setRequestLimit(3);522 ResourceCache::setRequestLimit(3);
523 523
524 _offscreenContext = new OffscreenGlCanvas();524 _glWidget = new GLCanvas();
525 _offscreenContext->create();525 _window->setCentralWidget(_glWidget);
526 _offscreenContext->makeCurrent();
527
528 _glWindow = new GlWindow(_offscreenContext->getContext());
529 526
530 QWidget* container = QWidget::createWindowContainer(_glWindow);
531 _window->setCentralWidget(container);
532 _window->restoreGeometry();527 _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());
539 528
540 _offscreenContext->makeCurrent();529 _glWidget->setFocusPolicy(Qt::StrongFocus);
541 initializeGL();530 _glWidget->setFocus();
542 // initialization continues in initializeGL when OpenGL context is ready
543#ifdef Q_OS_MAC531#ifdef Q_OS_MAC
544 // OSX doesn't seem to provide for hiding the cursor only on the GL widget532 // OSX doesn't seem to provide for hiding the cursor only on the GL widget
545 _window->setCursor(Qt::BlankCursor);533 _window->setCursor(Qt::BlankCursor);
@@ -547,11 +535,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 1 unmodified line
547 // On windows and linux, hiding the top level cursor also means it's invisible535 // On windows and linux, hiding the top level cursor also means it's invisible
548 // when hovering over the window menu, which is a pain, so only hide it for536 // when hovering over the window menu, which is a pain, so only hide it for
549 // the GL surface537 // the GL surface
550 container->setCursor(Qt::BlankCursor);538 _glWidget->setCursor(Qt::BlankCursor);
551#endif539#endif
552 540
553 // enable mouse tracking; otherwise, we only get drag events541 // 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
555 552
556 _toolWindow = new ToolWindow();553 _toolWindow = new ToolWindow();
557 _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);554 _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
@@ -858,6 +855,7 @@ void Application::initializeUi() { · 300 unmodified lines
858 offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));855 offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
859 offscreenUi->load("Root.qml");856 offscreenUi->load("Root.qml");
860 offscreenUi->load("RootMenu.qml");857 offscreenUi->load("RootMenu.qml");
858 _glWidget->installEventFilter(offscreenUi.data());
861 VrMenu::load();859 VrMenu::load();
862 VrMenu::executeQueuedLambdas();860 VrMenu::executeQueuedLambdas();
863 offscreenUi->setMouseTranslator([=](const QPointF& pt) {861 offscreenUi->setMouseTranslator([=](const QPointF& pt) {
@@ -1284,53 +1282,6 @@ bool Application::eventFilter(QObject* object, QEvent* event) { · 420 unmodified lines
1284 }1282 }
1285 }1283 }
1286 1284
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 }
1334 return false;1285 return false;
1335}1286}
1336 1287
@@ -4682,7 +4633,7 @@ void Application::shutdownPlugins() { · 3345 unmodified lines
4682}4633}
4683 4634
4684glm::uvec2 Application::getCanvasSize() const {4635glm::uvec2 Application::getCanvasSize() const {
4685 return toGlm(_glWindow->size());4636 return glm::uvec2(_glWidget->width(), _glWidget->height());
4686}4637}
4687 4638
4688glm::uvec2 Application::getUiSize() const {4639glm::uvec2 Application::getUiSize() const {
@@ -4702,7 +4653,7 @@ bool Application::isThrottleRendering() const { · 13 unmodified lines
4702}4653}
4703 4654
4704ivec2 Application::getTrueMouse() const {4655ivec2 Application::getTrueMouse() const {
4705 return toGlm(_glWindow->mapFromGlobal(QCursor::pos()));4656 return toGlm(_glWidget->mapFromGlobal(QCursor::pos()));
4706}4657}
4707 4658
4708bool Application::hasFocus() const {4659bool Application::hasFocus() const {
@@ -4760,11 +4711,6 @@ void Application::updateDisplayMode() { · 51 unmodified lines
4760 auto offscreenUi = DependencyManager::get<OffscreenUi>();4711 auto offscreenUi = DependencyManager::get<OffscreenUi>();
4761 DisplayPluginPointer oldDisplayPlugin = _displayPlugin;4712 DisplayPluginPointer oldDisplayPlugin = _displayPlugin;
4762 if (oldDisplayPlugin != newDisplayPlugin) {4713 if (oldDisplayPlugin != newDisplayPlugin) {
4763 if (oldDisplayPlugin) {
4764 oldDisplayPlugin->removeEventFilter(qApp);
4765 oldDisplayPlugin->removeEventFilter(offscreenUi.data());
4766 }
4767
4768 if (!_currentDisplayPluginActions.isEmpty()) {4714 if (!_currentDisplayPluginActions.isEmpty()) {
4769 auto menu = Menu::getInstance();4715 auto menu = Menu::getInstance();
4770 foreach(auto itemInfo, _currentDisplayPluginActions) {4716 foreach(auto itemInfo, _currentDisplayPluginActions) {
@@ -4776,16 +4722,7 @@ void Application::updateDisplayMode() { · 5 unmodified lines
4776 if (newDisplayPlugin) {4722 if (newDisplayPlugin) {
4777 _offscreenContext->makeCurrent();4723 _offscreenContext->makeCurrent();
4778 newDisplayPlugin->activate(this);4724 newDisplayPlugin->activate(this);
4779
4780 _offscreenContext->makeCurrent();4725 _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 }
4789 offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize()));4726 offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize()));
4790 _offscreenContext->makeCurrent();4727 _offscreenContext->makeCurrent();
4791 }4728 }
@@ -4882,10 +4819,6 @@ void Application::setIsOptionChecked(const QString& path, bool checked) { · 90 unmodified lines
4882 Menu::getInstance()->setIsOptionChecked(path, checked);4819 Menu::getInstance()->setIsOptionChecked(path, checked);
4883}4820}
4884 4821
4885GlWindow* Application::getVisibleWindow() {
4886 return _glWindow;
4887}
4888
4889mat4 Application::getEyeProjection(int eye) const {4822mat4 Application::getEyeProjection(int eye) const {
4890 if (isHMDMode()) {4823 if (isHMDMode()) {
4891 return getActiveDisplayPlugin()->getProjection((Eye)eye, _viewFrustum.getProjection());4824 return getActiveDisplayPlugin()->getProjection((Eye)eye, _viewFrustum.getProjection());
@@ -4941,3 +4874,12 @@ void Application::unsetFullscreen() { · 49 unmodified lines
4941 _window->setGeometry(_savedGeometry);4874 _window->setGeometry(_savedGeometry);
4942#endif4875#endif
4943}4876}
4877
4878
4879void Application::showDisplayPluginsTools() {
4880
4881}
4882
4883QGLWidget* Application::getPrimarySurface() {
4884 return _glWidget;
4885}