From b46ffbca0cfad41599873d4ca19dc79167c3955f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 23 Sep 2015 17:40:27 +0200 Subject: Fix up QOpenGLWidget transparency support The glColorMask call was troublesome. In addition, the Qt::WA_TranslucentBackground was misinterpreted and recommended misleadingly in the documentation. The hellogl2 example's --transparent argument was disfunctional in practice. Replace glColorMask with glBlendFuncSeparate. The hellogl2 example and the docs are now corrected wrt enabling semi-transparency in a QOpenGLWidget that is not a top-level (which is the most common case). Task-number: QTBUG-47276 Change-Id: I6f40e732d455f5efcf158649ac9a52ff9f240e85 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Gunnar Sletta --- examples/opengl/hellogl2/glwidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'examples/opengl/hellogl2/glwidget.cpp') diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp index 9738dcda20..6505ad3141 100644 --- a/examples/opengl/hellogl2/glwidget.cpp +++ b/examples/opengl/hellogl2/glwidget.cpp @@ -55,8 +55,11 @@ GLWidget::GLWidget(QWidget *parent) // --transparent causes the clear color to be transparent. Therefore, on systems that // support it, the widget will become transparent apart from the logo. m_transparent = QCoreApplication::arguments().contains(QStringLiteral("--transparent")); - if (m_transparent) - setAttribute(Qt::WA_TranslucentBackground); + if (m_transparent) { + QSurfaceFormat fmt = format(); + fmt.setAlphaBufferSize(8); + setFormat(fmt); + } } GLWidget::~GLWidget() -- cgit v1.2.3