summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl_qpa.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2010-11-18 13:03:59 +0100
committerJørgen Lind <jorgen.lind@nokia.com>2010-11-22 14:14:08 +0100
commit292f6a9ba1b5da049e4898525974c6f0575ccd65 (patch)
treeb44bdf07f56298d7206a180a41690c2de3371fc6 /src/opengl/qgl_qpa.cpp
parenta1acef227647b3043998f9ccf364ead5c29b882d (diff)
Lighthouse: move the currentContext functionality to QPlatformGLContext
This means the threading functionality has been delegated down to QPlatformGLContext. However, it is still possible to use QGLContext::currentContext to retrieve the QGLContext. This so that QGLFunctions, QGLShaderProgram etc can be used without a QGLWidget. Reviewed-by: paul
Diffstat (limited to 'src/opengl/qgl_qpa.cpp')
-rw-r--r--src/opengl/qgl_qpa.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 1197013c7d..28bea83f5b 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
-static QGLFormat qt_platformwindowformat_to_glformat(const QPlatformWindowFormat &format)
+QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format)
{
QGLFormat retFormat;
retFormat.setAccum(format.accum());
@@ -83,7 +83,7 @@ static QGLFormat qt_platformwindowformat_to_glformat(const QPlatformWindowFormat
return retFormat;
}
-static QPlatformWindowFormat qt_glformat_to_platformwindowformat(const QGLFormat &format)
+QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
{
QPlatformWindowFormat retFormat;
retFormat.setAccum(format.accum());
@@ -120,6 +120,12 @@ bool QGLFormat::hasOpenGL()
return QApplicationPrivate::platformIntegration()->hasOpenGL();
}
+void qDeleteQGLContext(void *handle)
+{
+ QGLContext *context = static_cast<QGLContext *>(handle);
+ delete context;
+}
+
bool QGLContext::chooseContext(const QGLContext* shareContext)
{
Q_D(QGLContext);
@@ -129,7 +135,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
QWidget *widget = static_cast<QWidget *>(d->paintDevice);
if (!widget->platformWindow()){
QGLFormat glformat = format();
- QPlatformWindowFormat winFormat = qt_glformat_to_platformwindowformat(glformat);
+ QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat);
if (shareContext) {
winFormat.setSharedContext(shareContext->d_func()->platformContext);
}
@@ -140,8 +146,11 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
}
d->platformContext = widget->platformWindow()->glContext();
Q_ASSERT(d->platformContext);
- d->glFormat = qt_platformwindowformat_to_glformat(d->platformContext->platformWindowFormat());
+ d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat());
d->valid =(bool) d->platformContext;
+ if (d->valid) {
+ d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ }
}
return d->valid;
@@ -254,13 +263,13 @@ class QGLTemporaryContextPrivate
{
public:
QWidget *widget;
- QGLContext *context;
+ QPlatformGLContext *context;
};
QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
: d(new QGLTemporaryContextPrivate)
{
- d->context = const_cast<QGLContext *>(QGLContext::currentContext());
+ d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext());
if (d->context)
d->context->doneCurrent();
d->widget = new QWidget;
@@ -269,7 +278,6 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
format.setWindowApi(QPlatformWindowFormat::OpenGL);
d->widget->winId();
-
d->widget->platformWindow()->glContext()->makeCurrent();
}