diff --git a/libraries/gl/src/gl/QOpenGLContextWrapper.cpp b/libraries/gl/src/gl/QOpenGLContextWrapper.cpp index 3e879df7af..6397d30e13 100644 --- a/libraries/gl/src/gl/QOpenGLContextWrapper.cpp +++ b/libraries/gl/src/gl/QOpenGLContextWrapper.cpp @@ -39,6 +39,11 @@ void QOpenGLContextWrapper::doneCurrent() { _context->doneCurrent(); } +void QOpenGLContextWrapper::setShareContext(QOpenGLContext* otherContext) { + _context->setShareContext(otherContext); +} + bool isCurrentContext(QOpenGLContext* context) { return QOpenGLContext::currentContext() == context; -} \ No newline at end of file +} + diff --git a/libraries/gl/src/gl/QOpenGLContextWrapper.h b/libraries/gl/src/gl/QOpenGLContextWrapper.h index 832119162c..b736253213 100644 --- a/libraries/gl/src/gl/QOpenGLContextWrapper.h +++ b/libraries/gl/src/gl/QOpenGLContextWrapper.h @@ -25,6 +25,12 @@ public: void swapBuffers(QSurface* surface); bool makeCurrent(QSurface* surface); void doneCurrent(); + void setShareContext(QOpenGLContext* otherContext); + + QOpenGLContext* getContext() { + return _context; + } + private: QOpenGLContext* _context { nullptr }; diff --git a/libraries/ui/src/QmlWebWindowClass.cpp b/libraries/ui/src/QmlWebWindowClass.cpp index eeadb361ae..d5cdc1fde9 100644 --- a/libraries/ui/src/QmlWebWindowClass.cpp +++ b/libraries/ui/src/QmlWebWindowClass.cpp @@ -110,7 +110,7 @@ QScriptValue QmlWebWindowClass::constructor(QScriptContext* context, QScriptEngi } QmlWebWindowClass::QmlWebWindowClass(QObject* qmlWindow) - : _isToolWindow(false), _windowId(++nextWindowId), _qmlWindow(qmlWindow) + : _windowId(++nextWindowId), _qmlWindow(qmlWindow) { qDebug() << "Created window with ID " << _windowId; Q_ASSERT(_qmlWindow); @@ -128,7 +128,7 @@ void QmlWebWindowClass::setVisible(bool visible) { return; } - auto qmlWindow = (QQuickItem*)_qmlWindow; + auto qmlWindow = asQuickItem(); if (qmlWindow->isEnabled() != visible) { qmlWindow->setEnabled(visible); emit visibilityChanged(visible); diff --git a/libraries/ui/src/QmlWebWindowClass.h b/libraries/ui/src/QmlWebWindowClass.h index 90d355e162..2b563e68ba 100644 --- a/libraries/ui/src/QmlWebWindowClass.h +++ b/libraries/ui/src/QmlWebWindowClass.h @@ -93,9 +93,12 @@ private: QQuickItem* asQuickItem() const; QmlScriptEventBridge* const _eventBridge { new QmlScriptEventBridge(this) }; - const bool _isToolWindow; - QObject* const _qmlWindow; + + // FIXME needs to be initialized in the ctor once we have support + // for tool window panes in QML + const bool _isToolWindow { false }; const int _windowId; + QObject* const _qmlWindow; }; #endif diff --git a/tests/ui/src/main.cpp b/tests/ui/src/main.cpp index 00d1f2dc00..59e7376f1b 100644 --- a/tests/ui/src/main.cpp +++ b/tests/ui/src/main.cpp @@ -26,8 +26,7 @@ #include #include -#include -#include +#include #include @@ -403,7 +402,6 @@ private: std::atomic _isFinished { false }; std::atomic _isRunning { false }; bool _wantSignals { true }; - bool _isThreaded { false }; QHash _timerFunctionMap; }; @@ -423,7 +421,7 @@ Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context); class QTestWindow : public QWindow { Q_OBJECT - QOpenGLContext* _context{ nullptr }; + QOpenGLContextWrapper* _context{ nullptr }; QSize _size; bool _altPressed{ false }; RateCounter fps; @@ -450,7 +448,7 @@ public: setSurfaceType(QSurface::OpenGLSurface); QSurfaceFormat format = getDefaultOpenGLSurfaceFormat(); setFormat(format); - _context = new QOpenGLContext; + _context = new QOpenGLContextWrapper(); _context->setFormat(format); _context->setShareContext(_chromiumShareContext->getContext()); } @@ -464,18 +462,6 @@ public: makeCurrent(); - - { - qDebug() << (const char*)glGetString(GL_VERSION); - QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this); - logger->initialize(); // initializes in the current context, i.e. ctx - logger->enableMessages(); - connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) { - qDebug() << debugMessage; - }); - //logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); - } - glewExperimental = true; glewInit(); glGetError(); @@ -492,7 +478,7 @@ public: auto offscreenUi = DependencyManager::set(); { - offscreenUi->create(_context); + offscreenUi->create(_context->getContext()); offscreenUi->setProxyWindow(this); connect(offscreenUi.data(), &OffscreenUi::textureUpdated, this, [this, offscreenUi](int textureId) {