summaryrefslogtreecommitdiffstats
path: root/examples/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/opengl')
-rw-r--r--examples/opengl/contextinfo/contextinfo.pro4
-rw-r--r--examples/opengl/contextinfo/main.cpp9
-rw-r--r--examples/opengl/contextinfo/widget.cpp20
-rw-r--r--examples/opengl/opengl.pro3
4 files changed, 36 insertions, 0 deletions
diff --git a/examples/opengl/contextinfo/contextinfo.pro b/examples/opengl/contextinfo/contextinfo.pro
index ddaa084f38..2836e5ea5a 100644
--- a/examples/opengl/contextinfo/contextinfo.pro
+++ b/examples/opengl/contextinfo/contextinfo.pro
@@ -7,3 +7,7 @@ SOURCES += main.cpp \
HEADERS += widget.h \
renderwindow.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/opengl/contextinfo
+INSTALLS += target
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);
}
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index ed8134743b..a102e08733 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -16,3 +16,6 @@ qtHaveModule(widgets) {
textures \
hellogles3
}
+
+EXAMPLE_FILES += \
+ legacy