| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
| 3 |
|
| 4 |
#include <QApplication> |
| 5 |
#include <QMainWindow> |
| 6 |
#include <QColorSpace> |
| 7 |
#include <QSurfaceFormat> |
| 8 |
#include <QCommandLineParser> |
| 9 |
#include <QCommandLineOption> |
| 10 |
#include "mainwindow.h" |
| 11 |
|
| 12 |
int main( int argc, char ** argv ) |
| 13 |
{ |
| 14 |
QApplication a( argc, argv ); |
| 15 |
|
| 16 |
QCoreApplication::setApplicationName("Qt QOpenGLWidget Example"); |
| 17 |
QCoreApplication::setOrganizationName("QtProject"); |
| 18 |
QCoreApplication::setApplicationVersion(QT_VERSION_STR); |
| 19 |
QCommandLineParser parser; |
| 20 |
parser.setApplicationDescription(QCoreApplication::applicationName()); |
| 21 |
parser.addHelpOption(); |
| 22 |
parser.addVersionOption(); |
| 23 |
QCommandLineOption multipleSampleOption("multisample", "Multisampling"); |
| 24 |
parser.addOption(multipleSampleOption); |
| 25 |
QCommandLineOption srgbOption("srgb", "Use sRGB Color Space"); |
| 26 |
parser.addOption(srgbOption); |
| 27 |
parser.process(a); |
| 28 |
|
| 29 |
QSurfaceFormat format; |
| 30 |
format.setDepthBufferSize(24); |
| 31 |
format.setStencilBufferSize(8); |
| 32 |
if (parser.isSet(srgbOption)) |
| 33 |
format.setColorSpace(QColorSpace::SRgb); |
| 34 |
if (parser.isSet(multipleSampleOption)) |
| 35 |
format.setSamples(4); |
| 36 |
QSurfaceFormat::setDefaultFormat(format); |
| 37 |
|
| 38 |
MainWindow mw; |
| 39 |
mw.resize(1280, 720); |
| 40 |
mw.show(); |
| 41 |
return a.exec(); |
| 42 |
} |