summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qopenglcontext.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2015-01-12 16:52:05 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-01-22 14:16:50 +0100
commit2bc038adc905497891294019007fcf0bf85f5638 (patch)
tree34f043e777b522dc1f0c098301371df2159770de /src/gui/kernel/qopenglcontext.cpp
parenta2b358e7f5f46472d21d4ea24ec0c2646bc51cc7 (diff)
Expose context loss
On platforms like Windows (and presumably on mobile devices too) the loss of the context (e.g. the underlying D3D device in case of ANGLE) is an event that can happen randomly and needs sufficient handling. Enhance QOpenGLContext::isValid() with the purpose of indicating context loss. Currently only the Windows EGL backend (ANGLE) has support for it. Other platforms may be added later. Task-number: QTBUG-43263 Change-Id: I8177694c1ee7cebbd5d330e34757fd94c563e6d6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qopenglcontext.cpp')
-rw-r--r--src/gui/kernel/qopenglcontext.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 3fccd6ba9a..90e9235353 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -590,10 +590,10 @@ QVariant QOpenGLContext::nativeHandle() const
*/
bool QOpenGLContext::create()
{
- if (isValid())
+ Q_D(QOpenGLContext);
+ if (d->platformGLContext)
destroy();
- Q_D(QOpenGLContext);
d->platformGLContext = QGuiApplicationPrivate::platformIntegration()->createPlatformOpenGLContext(this);
if (!d->platformGLContext)
return false;
@@ -676,6 +676,15 @@ QOpenGLContext::~QOpenGLContext()
/*!
Returns if this context is valid, i.e. has been successfully created.
+ On some platforms the return value of \c false for a context that was
+ successfully created previously indicates that the OpenGL context was lost.
+
+ The typical way to handle context loss scenarios in applications is to
+ check via this function whenever makeCurrent() fails and returns \c false.
+ If this function then returns \c false, recreate the underlying native
+ OpenGL context by calling create(), call makeCurrent() again and then
+ reinitialize all OpenGL resources.
+
\sa create()
*/
bool QOpenGLContext::isValid() const