From a89691fc6652521f03d99c7cb4b6fbf8f7f4f69d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 25 Feb 2015 12:11:35 -0800 Subject: [PATCH] switch GLCanvas back to being owned by Application --- interface/src/Application.cpp | 77 +++++++++---------- interface/src/Application.h | 13 ++-- interface/src/Camera.cpp | 2 +- interface/src/GLCanvas.h | 18 ++--- interface/src/UIUtil.cpp | 5 +- interface/src/audio/AudioToolBox.cpp | 3 +- interface/src/devices/OculusManager.cpp | 4 +- interface/src/devices/PrioVR.cpp | 2 +- interface/src/devices/SixenseManager.cpp | 2 +- interface/src/devices/TV3DManager.cpp | 4 +- .../ControllerScriptingInterface.cpp | 3 +- .../scripting/WindowScriptingInterface.cpp | 2 +- interface/src/ui/ApplicationOverlay.cpp | 30 ++++---- interface/src/ui/MetavoxelEditor.cpp | 2 +- interface/src/ui/PreferencesDialog.cpp | 2 +- interface/src/ui/Snapshot.cpp | 3 +- interface/src/ui/Stats.cpp | 8 +- 17 files changed, 93 insertions(+), 87 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index eb228f2874..772c314783 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -215,7 +215,7 @@ bool setupEssentials(int& argc, char** argv) { DependencyManager::registerInheritance(); // Set dependencies - auto glCanvas = DependencyManager::set(); + //auto glCanvasGlobal = DependencyManager::set(); auto addressManager = DependencyManager::set(); auto nodeList = DependencyManager::set(NodeType::Agent, listenPort); auto geometryCache = DependencyManager::set(); @@ -307,7 +307,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us - auto glCanvas = DependencyManager::get(); auto nodeList = DependencyManager::get(); _myAvatar = DependencyManager::get()->getMyAvatar(); @@ -447,16 +446,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : ResourceCache::setRequestLimit(3); - _window->setCentralWidget(glCanvas.data()); + _window->setCentralWidget(_glWidget); _window->restoreGeometry(); _window->setVisible(true); - glCanvas->setFocusPolicy(Qt::StrongFocus); - glCanvas->setFocus(); + _glWidget->setFocusPolicy(Qt::StrongFocus); + _glWidget->setFocus(); // enable mouse tracking; otherwise, we only get drag events - glCanvas->setMouseTracking(true); + _glWidget->setMouseTracking(true); _toolWindow = new ToolWindow(); _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint); @@ -474,7 +473,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : checkVersion(); - _overlays.init(glCanvas.data()); // do this before scripts load + _overlays.init(_glWidget); // do this before scripts load _runningScriptsWidget->setRunningScripts(getRunningScripts()); connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); @@ -533,6 +532,7 @@ void Application::aboutToQuit() { } void Application::cleanupBeforeQuit() { + qDebug() << "Application::cleanupBeforeQuit() ------------ BEGIN --------------"; _datagramProcessor.shutdown(); // tell the datagram processor we're shutting down, so it can short circuit _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts @@ -577,9 +577,12 @@ void Application::cleanupBeforeQuit() { // destroy the AudioClient so it and its thread have a chance to go down safely DependencyManager::destroy(); + + qDebug() << "Application::cleanupBeforeQuit() ------------ END --------------"; } Application::~Application() { + qDebug() << "Application::~Application() ------------ BEGIN --------------"; EntityTree* tree = _entities.getTree(); tree->lockForWrite(); _entities.getTree()->setSimulation(NULL); @@ -598,15 +601,19 @@ Application::~Application() { ModelEntityItem::cleanupLoadedAnimations() ; - DependencyManager::destroy(); + //DependencyManager::destroy(); + qDebug() << "Application::~Application() ------------ BEGIN CACHE CLEANUP --------------"; DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); + qDebug() << "Application::~Application() ------------ END CACHE CLEANUP --------------"; qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages + + qDebug() << "Application::~Application() ------------ END --------------"; } void Application::initializeGL() { @@ -691,7 +698,7 @@ void Application::paintGL() { if (OculusManager::isConnected()) { DependencyManager::get()->setFrameBufferSize(OculusManager::getRenderTargetSize()); } else { - QSize fbSize = DependencyManager::get()->getDeviceSize() * getRenderResolutionScale(); + QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); DependencyManager::get()->setFrameBufferSize(fbSize); } @@ -1058,8 +1065,7 @@ void Application::keyPressEvent(QKeyEvent* event) { if (isShifted) { _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f); if (TV3DManager::isConnected()) { - auto glCanvas = DependencyManager::get(); - TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); + TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); } } else { _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); @@ -1071,8 +1077,7 @@ void Application::keyPressEvent(QKeyEvent* event) { if (isShifted) { _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f); if (TV3DManager::isConnected()) { - auto glCanvas = DependencyManager::get(); - TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); + TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); } } else { @@ -1501,7 +1506,7 @@ void Application::idle() { { PerformanceTimer perfTimer("updateGL"); PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); - DependencyManager::get()->updateGL(); + _glWidget->updateGL(); } { PerformanceTimer perfTimer("rest"); @@ -1542,8 +1547,7 @@ void Application::setFullscreen(bool fullscreen) { } void Application::setEnable3DTVMode(bool enable3DTVMode) { - auto glCanvas = DependencyManager::get(); - resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); + resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); } void Application::setEnableVRMode(bool enableVRMode) { @@ -1568,8 +1572,7 @@ void Application::setEnableVRMode(bool enableVRMode) { _myCamera.setHmdRotation(glm::quat()); } - auto glCanvas = DependencyManager::get(); - resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); + resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); updateCursorVisibility(); } @@ -1580,9 +1583,8 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { bool Application::mouseOnScreen() const { if (OculusManager::isConnected()) { - auto glCanvas = DependencyManager::get(); - return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() && - getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight(); + return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() && + getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight(); } return true; } @@ -1792,8 +1794,7 @@ void Application::init() { _metavoxels.init(); - auto glCanvas = DependencyManager::get(); - _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect); + _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect); connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); @@ -1801,10 +1802,10 @@ void Application::init() { connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); // make sure our texture cache knows about window size changes - DependencyManager::get()->associateWithWidget(glCanvas.data()); + DependencyManager::get()->associateWithWidget(_glWidget); // initialize the GlowEffect with our widget - DependencyManager::get()->init(glCanvas.data(), + DependencyManager::get()->init(_glWidget, Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)); } @@ -2058,9 +2059,9 @@ void Application::updateCursor(float deltaTime) { void Application::updateCursorVisibility() { if (!_cursorVisible || Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { - DependencyManager::get()->setCursor(Qt::BlankCursor); + _glWidget->setCursor(Qt::BlankCursor); } else { - DependencyManager::get()->unsetCursor(); + _glWidget->unsetCursor(); } } @@ -2650,8 +2651,7 @@ void Application::updateShadowMap() { fbo->release(); - auto glCanvas = DependencyManager::get(); - glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); + glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); } const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; @@ -2701,7 +2701,7 @@ QImage Application::renderAvatarBillboard() { Glower glower; const int BILLBOARD_SIZE = 64; - renderRearViewMirror(QRect(0, DependencyManager::get()->getDeviceHeight() - BILLBOARD_SIZE, + renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true); @@ -2993,9 +2993,8 @@ bool Application::getCascadeShadowsEnabled() { } glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { - auto glCanvas = DependencyManager::get(); - float horizontalScale = glCanvas->getDeviceWidth() / 2.0f; - float verticalScale = glCanvas->getDeviceHeight() / 2.0f; + float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; + float verticalScale = _glWidget->getDeviceHeight() / 2.0f; // -1,-1 is 0,windowHeight // 1,1 is windowWidth,0 @@ -3014,7 +3013,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { // -1,-1 1,-1 glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale, - ((projectedPoint.y + 1.0) * -verticalScale) + glCanvas->getDeviceHeight()); + ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight()); return screenPoint; } @@ -3150,7 +3149,7 @@ void Application::resetSensors() { QScreen* currentScreen = _window->windowHandle()->screen(); QWindow* mainWindow = _window->windowHandle(); QPoint windowCenter = mainWindow->geometry().center(); - DependencyManager::get()->cursor().setPos(currentScreen, windowCenter); + _glWidget->cursor().setPos(currentScreen, windowCenter); _myAvatar->reset(); @@ -3786,7 +3785,7 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio void Application::loadDialog() { - QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get().data(), + QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), getPreviousScriptLocation(), tr("JavaScript Files (*.js)")); @@ -3827,7 +3826,7 @@ void Application::setScriptsLocation(const QString& scriptsLocation) { void Application::toggleLogDialog() { if (! _logDialog) { - _logDialog = new LogDialog(DependencyManager::get().data(), getLogger()); + _logDialog = new LogDialog(_glWidget, getLogger()); } if (_logDialog->isVisible()) { @@ -3884,7 +3883,7 @@ void Application::parseVersionXml() { } if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) { - new UpdateDialog(DependencyManager::get().data(), releaseNotes, latestVersion, downloadUrl); + new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl); } sender->deleteLater(); } @@ -3917,7 +3916,7 @@ void Application::takeSnapshot() { } if (!_snapshotShareDialog) { - _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get().data()); + _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); } _snapshotShareDialog->show(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 669187138c..9cd19c8259 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -171,7 +171,8 @@ public: bool event(QEvent* event); bool eventFilter(QObject* object, QEvent* event); - bool isThrottleRendering() const { return DependencyManager::get()->isThrottleRendering(); } + GLCanvas* getGLWidget() { return _glWidget; } + bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); } Camera* getCamera() { return &_myCamera; } ViewFrustum* getViewFrustum() { return &_viewFrustum; } @@ -195,8 +196,8 @@ public: bool mouseOnScreen() const; int getMouseX() const; int getMouseY() const; - int getTrueMouseX() const { return DependencyManager::get()->mapFromGlobal(QCursor::pos()).x(); } - int getTrueMouseY() const { return DependencyManager::get()->mapFromGlobal(QCursor::pos()).y(); } + int getTrueMouseX() const { return _glWidget->mapFromGlobal(QCursor::pos()).x(); } + int getTrueMouseY() const { return _glWidget->mapFromGlobal(QCursor::pos()).y(); } int getMouseDragStartedX() const; int getMouseDragStartedY() const; int getTrueMouseDragStartedX() const { return _mouseDragStartedX; } @@ -270,8 +271,8 @@ public: FileLogger* getLogger() { return _logger; } - glm::vec2 getViewportDimensions() const { return glm::vec2(DependencyManager::get()->getDeviceWidth(), - DependencyManager::get()->getDeviceHeight()); } + glm::vec2 getViewportDimensions() const { return glm::vec2(_glWidget->getDeviceWidth(), + _glWidget->getDeviceHeight()); } NodeToJurisdictionMap& getEntityServerJurisdictions() { return _entityServerJurisdictions; } void skipVersion(QString latestVersion); @@ -593,6 +594,8 @@ private: QThread _settingsThread; QTimer _settingsTimer; + + GLCanvas* _glWidget = new GLCanvas(); // our GLCanvas has a couple extra features }; #endif // hifi_Application_h diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index 5019599641..e334fd7c65 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -122,7 +122,7 @@ void Camera::setFarClip(float f) { } PickRay Camera::computePickRay(float x, float y) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); return computeViewPickRay(x / glCanvas->width(), y / glCanvas->height()); } diff --git a/interface/src/GLCanvas.h b/interface/src/GLCanvas.h index ee101743cf..9e75d92b42 100644 --- a/interface/src/GLCanvas.h +++ b/interface/src/GLCanvas.h @@ -16,14 +16,18 @@ #include #include -#include +//#include /// customized canvas that simply forwards requests/events to the singleton application -class GLCanvas : public QGLWidget, public Dependency { +class GLCanvas : public QGLWidget { Q_OBJECT - SINGLETON_DEPENDENCY public: + GLCanvas(); + virtual ~GLCanvas() { + qDebug() << "Deleting GLCanvas"; + } + bool isThrottleRendering() const; int getDeviceWidth() const; @@ -60,12 +64,8 @@ private slots: void activeChanged(Qt::ApplicationState state); void throttleRender(); bool eventFilter(QObject*, QEvent* event); - -private: - GLCanvas(); - ~GLCanvas() { - qDebug() << "Deleting GLCanvas"; - } + }; + #endif // hifi_GLCanvas_h diff --git a/interface/src/UIUtil.cpp b/interface/src/UIUtil.cpp index 19d3a51917..03195c5e75 100644 --- a/interface/src/UIUtil.cpp +++ b/interface/src/UIUtil.cpp @@ -12,7 +12,8 @@ #include #include -#include "DependencyManager.h" +//#include "DependencyManager.h" +#include "Application.h" #include "GLCanvas.h" #include "UIUtil.h" @@ -44,7 +45,7 @@ int UIUtil::getWindowTitleBarHeight(const QWidget* window) { // this function at all. If you mix both you will end up with inconsistent results // across platforms. void UIUtil::scaleWidgetFontSizes(QWidget* widget) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); // This is the base dpi that we are targetting. This is based on Mac OSXs default DPI, // and is the basis for all font sizes. diff --git a/interface/src/audio/AudioToolBox.cpp b/interface/src/audio/AudioToolBox.cpp index 924c8105ea..e12b7bcbb0 100644 --- a/interface/src/audio/AudioToolBox.cpp +++ b/interface/src/audio/AudioToolBox.cpp @@ -16,6 +16,7 @@ #include #include +#include "Application.h" #include "AudioToolBox.h" // Mute icon configration @@ -37,7 +38,7 @@ bool AudioToolBox::mousePressEvent(int x, int y) { void AudioToolBox::render(int x, int y, bool boxed) { glEnable(GL_TEXTURE_2D); - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); if (_micTextureId == 0) { _micTextureId = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic.svg")); } diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 14d1939198..4d864d8cec 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -566,7 +566,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p } // restore our normal viewport - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); glMatrixMode(GL_PROJECTION); @@ -585,7 +585,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p void OculusManager::renderDistortionMesh(ovrPosef eyeRenderPose[ovrEye_Count]) { glLoadIdentity(); - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); glOrtho(0, glCanvas->getDeviceWidth(), 0, glCanvas->getDeviceHeight(), -1.0, 1.0); glDisable(GL_DEPTH_TEST); diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index b3342ac2bd..428c223eb7 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -216,7 +216,7 @@ void PrioVR::renderCalibrationCountdown() { static TextRenderer* textRenderer = TextRenderer::getInstance(MONO_FONT_FAMILY, 18, QFont::Bold, false, TextRenderer::OUTLINE_EFFECT, 2); QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "..."; - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); textRenderer->draw((glCanvas->width() - textRenderer->computeExtent(text.constData()).x) / 2, glCanvas->height() / 2, text, glm::vec4(1,1,1,1)); diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index 609ac7b349..ce6ca57c69 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -472,7 +472,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers) //Injecting mouse movements and clicks void SixenseManager::emulateMouse(PalmData* palm, int index) { MyAvatar* avatar = DependencyManager::get()->getMyAvatar(); - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); QPoint pos; Qt::MouseButton bumperButton; diff --git a/interface/src/devices/TV3DManager.cpp b/interface/src/devices/TV3DManager.cpp index 9af13c461e..205ebfd29d 100644 --- a/interface/src/devices/TV3DManager.cpp +++ b/interface/src/devices/TV3DManager.cpp @@ -35,7 +35,7 @@ bool TV3DManager::isConnected() { } void TV3DManager::connect() { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); int width = glCanvas->getDeviceWidth(); int height = glCanvas->getDeviceHeight(); Camera& camera = *Application::getInstance()->getCamera(); @@ -93,7 +93,7 @@ void TV3DManager::display(Camera& whichCamera) { // left eye portal int portalX = 0; int portalY = 0; - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); QSize deviceSize = glCanvas->getDeviceSize() * Application::getInstance()->getRenderResolutionScale(); int portalW = deviceSize.width() / 2; diff --git a/interface/src/scripting/ControllerScriptingInterface.cpp b/interface/src/scripting/ControllerScriptingInterface.cpp index 2188f45374..35c24346d2 100644 --- a/interface/src/scripting/ControllerScriptingInterface.cpp +++ b/interface/src/scripting/ControllerScriptingInterface.cpp @@ -15,6 +15,7 @@ #include #include +#include "Application.h" #include "devices/MotionTracker.h" #include "devices/SixenseManager.h" #include "ControllerScriptingInterface.h" @@ -285,7 +286,7 @@ void ControllerScriptingInterface::releaseJoystick(int joystickIndex) { } glm::vec2 ControllerScriptingInterface::getViewportDimensions() const { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); return glm::vec2(glCanvas->width(), glCanvas->height()); } diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index fc3eefe260..8ec9fbbb82 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -44,7 +44,7 @@ WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title } QScriptValue WindowScriptingInterface::hasFocus() { - return DependencyManager::get()->hasFocus(); + return Application::getInstance()->getGLWidget()->hasFocus(); } void WindowScriptingInterface::setFocus() { diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 632e76c840..0c5941366f 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -170,7 +170,7 @@ ApplicationOverlay::~ApplicationOverlay() { void ApplicationOverlay::renderOverlay(bool renderToTexture) { PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()"); Overlays& overlays = qApp->getOverlays(); - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); _textureFov = glm::radians(_oculusUIAngularSize); _textureAspectRatio = (float)glCanvas->getDeviceWidth() / (float)glCanvas->getDeviceHeight(); @@ -239,7 +239,7 @@ void ApplicationOverlay::displayOverlayTexture() { if (_alpha == 0.0f) { return; } - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); glEnable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); @@ -401,7 +401,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as glm::vec2(1.0f, 0.0f), glm::vec2(0.0f, 0.0f), overlayColor); - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); if (_crosshairTexture == 0) { _crosshairTexture = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png")); } @@ -451,7 +451,7 @@ void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origi //Caculate the click location using one of the sixense controllers. Scale is not applied QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm); @@ -528,7 +528,7 @@ bool ApplicationOverlay::calculateRayUICollisionPoint(const glm::vec3& position, //Renders optional pointers void ApplicationOverlay::renderPointers() { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); //lazily load crosshair texture if (_crosshairTexture == 0) { @@ -575,7 +575,7 @@ void ApplicationOverlay::renderPointers() { } void ApplicationOverlay::renderControllerPointers() { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); //Static variables used for storing controller state @@ -722,7 +722,7 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool if (!_magnifier) { return; } - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); const int widgetWidth = glCanvas->width(); const int widgetHeight = glCanvas->height(); @@ -787,7 +787,7 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool } void ApplicationOverlay::renderAudioMeter() { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); auto audio = DependencyManager::get(); // Audio VU Meter and Mute Icon @@ -905,7 +905,7 @@ void ApplicationOverlay::renderStatsAndLogs() { Application* application = Application::getInstance(); QSharedPointer bandwidthRecorder = DependencyManager::get(); - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor(); NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay(); @@ -943,7 +943,7 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() { auto nodeList = DependencyManager::get(); if (nodeList && !nodeList->getDomainHandler().isConnected()) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); auto geometryCache = DependencyManager::get(); int width = glCanvas->width(); int height = glCanvas->height(); @@ -1087,7 +1087,7 @@ void ApplicationOverlay::TexturedHemisphere::cleanupVBO() { } void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() { - QSize size = DependencyManager::get()->getDeviceSize(); + QSize size = Application::getInstance()->getGLWidget()->getDeviceSize(); if (_framebufferObject != NULL && size == _framebufferObject->size()) { // Already build return; @@ -1138,7 +1138,7 @@ void ApplicationOverlay::TexturedHemisphere::render() { glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const { - QSize screenSize = DependencyManager::get()->getDeviceSize(); + QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); float yaw = -(screenPos.x / screenSize.width() - 0.5f) * MOUSE_YAW_RANGE; float pitch = (screenPos.y / screenSize.height() - 0.5f) * MOUSE_PITCH_RANGE; @@ -1146,7 +1146,7 @@ glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const { } glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const { - QSize screenSize = DependencyManager::get()->getDeviceSize(); + QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); float x = (-sphericalPos.x / MOUSE_YAW_RANGE + 0.5f) * screenSize.width(); float y = (sphericalPos.y / MOUSE_PITCH_RANGE + 0.5f) * screenSize.height(); @@ -1154,7 +1154,7 @@ glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const { } glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const { - QSize screenSize = DependencyManager::get()->getDeviceSize(); + QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); float x = (-sphericalPos.x / (_textureFov * _textureAspectRatio) + 0.5f) * screenSize.width(); float y = (sphericalPos.y / _textureFov + 0.5f) * screenSize.height(); @@ -1162,7 +1162,7 @@ glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const { } glm::vec2 ApplicationOverlay::overlayToSpherical(glm::vec2 overlayPos) const { - QSize screenSize = DependencyManager::get()->getDeviceSize(); + QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); float yaw = -(overlayPos.x / screenSize.width() - 0.5f) * _textureFov * _textureAspectRatio; float pitch = (overlayPos.y / screenSize.height() - 0.5f) * _textureFov; diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index bead5c743f..34c6ec9a30 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -140,7 +140,7 @@ MetavoxelEditor::MetavoxelEditor(QWidget* parent) : connect(Application::getInstance()->getMetavoxels(), &MetavoxelSystem::rendering, this, &MetavoxelEditor::renderPreview); - DependencyManager::get()->installEventFilter(this); + Application::getInstance()->getGLWidget()->installEventFilter(this); show(); diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 1a3ad541c9..fa63079290 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -235,7 +235,7 @@ void PreferencesDialog::savePreferences() { myAvatar->setLeanScale(ui.leanScaleSpin->value()); myAvatar->setClampedTargetScale(ui.avatarScaleSpin->value()); - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height()); DependencyManager::get()->getMyAvatar()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value()); diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 9f8603e2ca..5a3109ff64 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -23,6 +23,7 @@ #include #include +#include "Application.h" #include "Snapshot.h" // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg @@ -93,7 +94,7 @@ QTemporaryFile* Snapshot::saveTempSnapshot() { } QFile* Snapshot::savedFileForSnapshot(bool isTemporary) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); QImage shot = glCanvas->grabFrameBuffer(); Avatar* avatar = DependencyManager::get()->getMyAvatar(); diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 7617adf01c..a4bb60bf7c 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -62,7 +62,7 @@ Stats::Stats(): _metavoxelReceiveProgress(0), _metavoxelReceiveTotal(0) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); resetWidth(glCanvas->width(), 0); } @@ -73,7 +73,7 @@ void Stats::toggleExpanded() { // called on mouse click release // check for clicks over stats in order to expand or contract them void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); if (0 != glm::compMax(glm::abs(glm::ivec2(mouseX - mouseDragStartedX, mouseY - mouseDragStartedY)))) { // not worried about dragging on stats @@ -128,7 +128,7 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD } void Stats::resetWidth(int width, int horizontalOffset) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); int extraSpace = glCanvas->width() - horizontalOffset -2 - STATS_GENERAL_MIN_WIDTH - (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0) @@ -202,7 +202,7 @@ void Stats::display( int outKbitsPerSecond, int voxelPacketsToProcess) { - auto glCanvas = DependencyManager::get(); + auto glCanvas = Application::getInstance()->getGLWidget(); unsigned int backgroundColor = 0x33333399; int verticalOffset = 0, lines = 0;