Init QML GL from share context

This commit is contained in:
Zach Pomerantz 2016-04-11 13:28:33 -07:00
parent 52958ffc70
commit ab72d8d8fb
5 changed files with 9 additions and 13 deletions

View file

@ -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<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
const QHash<QString, Application::AcceptURLMethod> 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

View file

@ -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;

View file

@ -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<char**>(argv), startupTime);
// If we failed the OpenGLVersion check, log it.
if (override) {
auto& accountManager = AccountManager::getInstance();

View file

@ -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){

View file

@ -15,6 +15,8 @@
#include <QtQuick/QQuickWindow>
#include <QtQml/QtQml>
#include <gl/GLHelpers.h>
#include <AbstractUriHandler.h>
#include <AccountManager.h>