summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl_qpa.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-01-20 08:44:27 +0100
committerJørgen Lind <jorgen.lind@nokia.com>2011-01-25 19:07:35 +0100
commit37207d16cb51616c0b506dcc57126ff06c9073a9 (patch)
treee6079db4b9f9e1ee014d14086be79b6967adf98a /src/opengl/qgl_qpa.cpp
parentfd28a6ab14fc3c54c443718d405eeb9f98c7dd27 (diff)
Make QGLContext::fromPlatformGLContext show correct sharing
information. Prior to this, if a context was created with QGLWidget it would setup the sharing correct, but all sharing actually created on a QPlatformGLContext level was ignored by the QGLContext, thus indicating that it wasnt sharing with any other context.
Diffstat (limited to 'src/opengl/qgl_qpa.cpp')
-rw-r--r--src/opengl/qgl_qpa.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 52eb57fd88..0f4b3058ea 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -115,6 +115,16 @@ QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
return retFormat;
}
+void QGLContextPrivate::setupSharing() {
+ Q_Q(QGLContext);
+ QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext();
+ if (sharedPlatformGLContext) {
+ QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
+ sharing = true;
+ QGLContextGroup::addShare(q,actualSharedContext);
+ }
+}
+
bool QGLFormat::hasOpenGL()
{
return QApplicationPrivate::platformIntegration()->hasOpenGL();
@@ -151,19 +161,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
if (d->valid) {
d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
}
+ d->setupSharing();
}
- if (d->valid) {
- QPlatformGLContext *sharedPlatformGLContext = d->platformContext->platformWindowFormat().sharedGLContext();
- if (sharedPlatformGLContext) {
- QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
- if (actualSharedContext == shareContext) {
- d->sharing = true;//Will add combination in QGLContext::create
- }else {
- QGLContextGroup::addShare(this,actualSharedContext);
- }
- }
- }
return d->valid;
}
@@ -372,6 +372,9 @@ QGLContext::QGLContext(QPlatformGLContext *platformContext)
Q_D(QGLContext);
d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()));
d->platformContext = platformContext;
+ d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->valid = true;
+ d->setupSharing();
}
QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext)
@@ -384,11 +387,6 @@ QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContex
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;
}