diff options
Diffstat (limited to 'examples/opengl')
-rw-r--r-- | examples/opengl/hellogl2/glwidget.cpp | 6 | ||||
-rw-r--r-- | examples/opengl/hellogl2/glwidget.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp index c8db3047a1..7764fa8dfc 100644 --- a/examples/opengl/hellogl2/glwidget.cpp +++ b/examples/opengl/hellogl2/glwidget.cpp @@ -52,6 +52,11 @@ GLWidget::GLWidget(QWidget *parent) m_program(0) { m_core = QCoreApplication::arguments().contains(QStringLiteral("--coreprofile")); + // --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); } GLWidget::~GLWidget() @@ -183,6 +188,7 @@ void GLWidget::initializeGL() connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &GLWidget::cleanup); initializeOpenGLFunctions(); + glClearColor(0, 0, 0, m_transparent ? 0 : 1); m_program = new QOpenGLShaderProgram; m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, m_core ? vertexShaderSourceCore : vertexShaderSource); diff --git a/examples/opengl/hellogl2/glwidget.h b/examples/opengl/hellogl2/glwidget.h index fcc6225999..2d642649f1 100644 --- a/examples/opengl/hellogl2/glwidget.h +++ b/examples/opengl/hellogl2/glwidget.h @@ -98,6 +98,7 @@ private: QMatrix4x4 m_proj; QMatrix4x4 m_camera; QMatrix4x4 m_world; + bool m_transparent; }; #endif |