From 759b3f49c52c69f0a3ea2df014afbd3259e2bb83 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Apr 2016 09:27:18 +0200 Subject: OpenGL/contextinfo-Example: Add command line options and status label. Add command line options to be able to set the QCoreApplication attributes that influence Open GL context creation and add a status label at the bottom that displays it besides the QT_OPENGL environment variable. Task-number: QTBUG-52693 Change-Id: Id9793292596e0feb3da5220fde2e5b2e495f87ff Reviewed-by: Laszlo Agocs --- examples/opengl/contextinfo/widget.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'examples/opengl/contextinfo/widget.cpp') diff --git a/examples/opengl/contextinfo/widget.cpp b/examples/opengl/contextinfo/widget.cpp index 2d36fe4265..fb2caa6796 100644 --- a/examples/opengl/contextinfo/widget.cpp +++ b/examples/opengl/contextinfo/widget.cpp @@ -50,10 +50,12 @@ #include #include #include +#include #include #include #include #include +#include struct Version { const char *str; @@ -225,6 +227,24 @@ Widget::Widget(QWidget *parent) m_renderWindowContainer = new QWidget; addRenderWindow(); + QString description; + QTextStream str(&description); + str << "Qt " << QT_VERSION_STR << ' ' << QGuiApplication::platformName(); + const char *openGlVariables[] = + {"QT_ANGLE_PLATFORM", "QT_OPENGL", "QT_OPENGL_BUGLIST", "QT_OPENGL_DLL"}; + const size_t variableCount = sizeof(openGlVariables) / sizeof(openGlVariables[0]); + for (size_t v = 0; v < variableCount; ++v) { + if (qEnvironmentVariableIsSet(openGlVariables[v])) + str << ' ' << openGlVariables[v] << '=' << qgetenv(openGlVariables[v]); + } + if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) + str << " Qt::AA_UseOpenGLES"; + if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) + str << " Qt::AA_UseSoftwareOpenGL"; + if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL)) + str << " Qt::AA_UseSoftwareOpenGL"; + layout->addWidget(new QLabel(description)); + setLayout(layout); } -- cgit v1.2.3