diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-04-20 09:27:18 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-04-23 06:10:45 +0000 |
commit | 759b3f49c52c69f0a3ea2df014afbd3259e2bb83 (patch) | |
tree | c24ac96e5a5f2cf2f5886c50164a3ee631c39496 /examples/opengl | |
parent | 84a49594d0bde29668fb66187ac1ef2c842393a3 (diff) |
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 <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'examples/opengl')
-rw-r--r-- | examples/opengl/contextinfo/main.cpp | 9 | ||||
-rw-r--r-- | examples/opengl/contextinfo/widget.cpp | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/examples/opengl/contextinfo/main.cpp b/examples/opengl/contextinfo/main.cpp index 0a75e10b29..8451551b7b 100644 --- a/examples/opengl/contextinfo/main.cpp +++ b/examples/opengl/contextinfo/main.cpp @@ -43,6 +43,15 @@ int main(int argc, char **argv) { + for (int i = 1; i < argc; ++i) { + if (!qstrcmp(argv[i], "-g")) + QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); + else if (!qstrcmp(argv[i], "-s")) + QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL); + else if (!qstrcmp(argv[i], "-d")) + QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); + } + QApplication app(argc, argv); Widget w; 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 <QPushButton> #include <QTextEdit> #include <QSplitter> +#include <QGuiApplication> #include <QSurfaceFormat> #include <QOpenGLContext> #include <QOpenGLFunctions> #include <QDebug> +#include <QTextStream> 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); } |