summaryrefslogtreecommitdiffstats
path: root/examples/opengl/contextinfo
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-04-27 09:18:05 +0200
committerLiang Qi <liang.qi@qt.io>2016-04-27 09:18:05 +0200
commit23a36fd2bfcdb57849deaa1e10e6e3f7b1156ed8 (patch)
treeb527c7e3ba4a831b542b0bccfb6a5a748a8a4fd9 /examples/opengl/contextinfo
parentc003a18ee332abf2387172eb0856a176a32a6c8f (diff)
parent072f5b513e486e884ea7fa4a1cac9aedf3846374 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/corelib/io/qprocess_win.cpp src/widgets/itemviews/qheaderview.cpp Change-Id: I0a59ade9cd6e91f770fdf298a7d72a41e79fd761
Diffstat (limited to 'examples/opengl/contextinfo')
-rw-r--r--examples/opengl/contextinfo/main.cpp9
-rw-r--r--examples/opengl/contextinfo/widget.cpp20
2 files changed, 29 insertions, 0 deletions
diff --git a/examples/opengl/contextinfo/main.cpp b/examples/opengl/contextinfo/main.cpp
index f8bca02527..88ab4a7334 100644
--- a/examples/opengl/contextinfo/main.cpp
+++ b/examples/opengl/contextinfo/main.cpp
@@ -53,6 +53,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 a3bda7b420..fc21983f38 100644
--- a/examples/opengl/contextinfo/widget.cpp
+++ b/examples/opengl/contextinfo/widget.cpp
@@ -60,10 +60,12 @@
#include <QPushButton>
#include <QTextEdit>
#include <QSplitter>
+#include <QGuiApplication>
#include <QSurfaceFormat>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <QDebug>
+#include <QTextStream>
struct Version {
const char *str;
@@ -235,6 +237,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);
}