diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-19 14:18:21 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-19 14:52:54 (GMT) |
commit | 6241e39cff9311c943430ff2f31236b13618f2ac (patch) | |
tree | 471d4e01c1e3a4d2e67f189de5a384aa98526521 /src/opengl | |
parent | a3b627e1c5ce03a2500ab35c64729b1995639dcc (diff) | |
download | Qt-6241e39cff9311c943430ff2f31236b13618f2ac.zip Qt-6241e39cff9311c943430ff2f31236b13618f2ac.tar.gz Qt-6241e39cff9311c943430ff2f31236b13618f2ac.tar.bz2 |
Full translucent background support in xcb and xlib backend.
Make sure to pick an alpha visual also for non-GL surface types, and to
ask for alpha in the window format if the WA_TranslucentBackground
attribute is set.
Reviewed-by: Janusz Lewandowski
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 18 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 994344c..9da650f 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -150,6 +150,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (shareContext) { winFormat.setSharedContext(shareContext->d_func()->platformContext); } + if (widget->testAttribute(Qt::WA_TranslucentBackground)) + winFormat.setAlpha(true); winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); winFormat.setWindowSurface(false); widget->setPlatformWindowFormat(winFormat); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 49b3dc2..ff57446 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -542,19 +542,27 @@ void QGLWindowSurface::beginPaint(const QRegion &) d_ptr->did_paint = true; updateGeometry(); - if (!context()) - return; - int clearFlags = 0; - if (context()->d_func()->workaround_needsFullClearOnEveryFrame) + QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext); + + if (!ctx) + return; + + if (ctx->d_func()->workaround_needsFullClearOnEveryFrame) clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; - else if (context()->format().alpha()) + else if (ctx->format().alpha()) clearFlags = GL_COLOR_BUFFER_BIT; if (clearFlags) { + if (d_ptr->fbo) + d_ptr->fbo->bind(); + glClearColor(0.0, 0.0, 0.0, 0.0); glClear(clearFlags); + + if (d_ptr->fbo) + d_ptr->fbo->release(); } } |