05fc3aef53
Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
60 lines
2.0 KiB
C++
60 lines
2.0 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#include <QApplication>
|
|
#include <QSurfaceFormat>
|
|
#include <QScreen>
|
|
#include <QCommandLineParser>
|
|
#include <QCommandLineOption>
|
|
|
|
#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 (parser.isSet(multipleSampleOption))
|
|
fmt.setSamples(4);
|
|
if (parser.isSet(coreProfileOption)) {
|
|
fmt.setVersion(3, 2);
|
|
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
|
}
|
|
QSurfaceFormat::setDefaultFormat(fmt);
|
|
|
|
MainWindow mainWindow;
|
|
|
|
GLWidget::setTransparent(parser.isSet(transparentOption));
|
|
if (GLWidget::isTransparent()) {
|
|
mainWindow.setAttribute(Qt::WA_TranslucentBackground);
|
|
mainWindow.setAttribute(Qt::WA_NoSystemBackground, false);
|
|
}
|
|
mainWindow.resize(mainWindow.sizeHint());
|
|
int desktopArea = QGuiApplication::primaryScreen()->size().width() *
|
|
QGuiApplication::primaryScreen()->size().height();
|
|
int widgetArea = mainWindow.width() * mainWindow.height();
|
|
if (((float)widgetArea / (float)desktopArea) < 0.75f)
|
|
mainWindow.show();
|
|
else
|
|
mainWindow.showMaximized();
|
|
return app.exec();
|
|
}
|