diff options
-rw-r--r-- | src/opengl/qgl.cpp | 12 | ||||
-rw-r--r-- | src/opengl/qgl.h | 2 | ||||
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 20 |
3 files changed, 22 insertions, 12 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5eb4c16..111a3e4 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3160,18 +3160,6 @@ void QGLContext::setDevice(QPaintDevice *pDev) } } -QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext) -{ - if (!platformContext) - return 0; - if (platformContext->qGLContextHandle()) { - return reinterpret_cast<QGLContext *>(platformContext->qGLContextHandle()); - } - QGLContext *glContext = new QGLContext(platformContext); - glContext->create(); - return glContext; -} - /*! \fn bool QGLContext::isValid() const diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index f5e0bd7..ff135fa 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -383,7 +383,9 @@ public: static const QGLContext* currentContext(); +#ifdef Q_WS_QPA static QGLContext *fromPlatformGLContext(QPlatformGLContext *platformContext); +#endif protected: virtual bool chooseContext(const QGLContext* shareContext = 0); diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index e997704..d45f246 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -360,4 +360,24 @@ void QGLWidget::setColormap(const QGLColormap & c) Q_UNUSED(c); } + +QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext) +{ + if (!platformContext) + return 0; + if (platformContext->qGLContextHandle()) { + return reinterpret_cast<QGLContext *>(platformContext->qGLContextHandle()); + } + QGLContext *glContext = new QGLContext(platformContext); + //Dont call create on context. This can cause the platformFormat to be set on the widget, which + //will cause the platformWindow to be recreated. + glContext->d_func()->platformContext->setQGLContextHandle(glContext,qDeleteQGLContext); + QGLFormat format = QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()); + glContext->d_func()->glFormat = format; + glContext->d_func()->valid = true; + + return glContext; +} + + QT_END_NAMESPACE |