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>
This commit is contained in:
parent
84a49594d0
commit
759b3f49c5
@ -43,6 +43,15 @@
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
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);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
Widget w;
|
Widget w;
|
||||||
|
@ -50,10 +50,12 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QSurfaceFormat>
|
#include <QSurfaceFormat>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
struct Version {
|
struct Version {
|
||||||
const char *str;
|
const char *str;
|
||||||
@ -225,6 +227,24 @@ Widget::Widget(QWidget *parent)
|
|||||||
m_renderWindowContainer = new QWidget;
|
m_renderWindowContainer = new QWidget;
|
||||||
addRenderWindow();
|
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);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user