From b3717fc7f01ae078faf066538ddc80fca016ef0c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Aug 2017 16:21:17 +0200 Subject: OpenGL examples: Introduce QCommandLineParser Task-number: QTBUG-60626 Change-Id: I6d102327c89206fcdce10f3ac04e112270b11ad2 Reviewed-by: Laszlo Agocs --- examples/opengl/hellogl2/main.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'examples/opengl/hellogl2/main.cpp') diff --git a/examples/opengl/hellogl2/main.cpp b/examples/opengl/hellogl2/main.cpp index 143f659eb6..b52a5a37d3 100644 --- a/examples/opengl/hellogl2/main.cpp +++ b/examples/opengl/hellogl2/main.cpp @@ -51,25 +51,46 @@ #include #include #include +#include +#include +#include "glwidget.h" #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); + QCoreApplication::setApplicationName("Qt Hello GL 2 Example"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::applicationName()); + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption multipleSampleOption("multisample", "Multisampling"); + parser.addOption(multipleSampleOption); + QCommandLineOption coreProfileOption("coreprofile", "Use core profile"); + parser.addOption(coreProfileOption); + QCommandLineOption transparentOption("transparent", "Transparent window"); + parser.addOption(transparentOption); + + parser.process(app); + QSurfaceFormat fmt; fmt.setDepthBufferSize(24); - if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) + if (parser.isSet(multipleSampleOption)) fmt.setSamples(4); - if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) { + if (parser.isSet(coreProfileOption)) { fmt.setVersion(3, 2); fmt.setProfile(QSurfaceFormat::CoreProfile); } QSurfaceFormat::setDefaultFormat(fmt); MainWindow mainWindow; - if (QCoreApplication::arguments().contains(QStringLiteral("--transparent"))) { + + GLWidget::setTransparent(parser.isSet(transparentOption)); + if (GLWidget::isTransparent()) { mainWindow.setAttribute(Qt::WA_TranslucentBackground); mainWindow.setAttribute(Qt::WA_NoSystemBackground, false); } -- cgit v1.2.3