Commit 759b3f49 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by Friedemann Kleint
Browse files

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: default avatarLaszlo Agocs <laszlo.agocs@theqtcompany.com>
parent 84a49594
Branches
Tags
No related merge requests found
Showing with 29 additions and 0 deletions
......@@ -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;
......
......@@ -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);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment