From ab72d8d8fb4a3744d59a4aa6a3e22d58171c364d Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Mon, 11 Apr 2016 13:28:33 -0700 Subject: [PATCH] Init QML GL from share context --- interface/src/Application.cpp | 5 ----- interface/src/Application.h | 5 ----- interface/src/main.cpp | 4 +--- libraries/gl/src/gl/OffscreenQmlSurface.cpp | 6 ++++++ libraries/ui/src/OffscreenUi.cpp | 2 ++ 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0c2cd49ef5..ce7408368d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -199,8 +199,6 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).append("/script.js"); #endif -QJsonObject Application::_glData {}; - Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); const QHash Application::_acceptedExtensions { @@ -1322,9 +1320,6 @@ void Application::initializeUi() { auto rootContext = offscreenUi->getRootContext(); - // First set the GL property, so the desktop can use it for graphics workarounds - rootContext->setContextProperty("GL", _glData); - offscreenUi->setProxyWindow(_window->windowHandle()); offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/")); // OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to diff --git a/interface/src/Application.h b/interface/src/Application.h index 4f1badf0be..116d2b2137 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -96,9 +96,6 @@ public: static void initPlugins(); static void shutdownPlugins(); - // Expose the gl metadata to QML - static void setGL(const QJsonObject& glData) { _glData = glData; } - Application(int& argc, char** argv, QElapsedTimer& startup_time); ~Application(); @@ -382,8 +379,6 @@ private: void maybeToggleMenuVisible(QMouseEvent* event) const; - static QJsonObject _glData; - MainWindow* _window; QElapsedTimer& _sessionRunTimer; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 4fce190c2c..f41046f7c2 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -140,13 +140,11 @@ int main(int argc, const char* argv[]) { // or in the main window ctor, before GL startup. Application::initPlugins(); - // GL must be available to the root QML context on startup. - Application::setGL(glData); - int exitCode; { QSettings::setDefaultFormat(QSettings::IniFormat); Application app(argc, const_cast(argv), startupTime); + // If we failed the OpenGLVersion check, log it. if (override) { auto& accountManager = AccountManager::getInstance(); diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index 1d7824f789..6645910699 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -27,6 +27,7 @@ #include "OffscreenGLCanvas.h" #include "GLEscrow.h" +#include "GLHelpers.h" // Time between receiving a request to render the offscreen UI actually triggering @@ -222,6 +223,11 @@ void OffscreenQmlRenderThread::init() { return; } + // Expose GL data to QML + auto glData = getGLContextData(); + auto setGL = [=]{ _surface->getRootContext()->setContextProperty("GL", glData); }; + _surface->executeOnUiThread(setGL); + _renderControl->initialize(_canvas.getContext()); setupFbo(); _escrow.setRecycler([this](GLuint texture){ diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 269cf86e2d..68732b96bf 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include