aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@qt.io>2019-06-24 14:26:07 +0300
committerJoni Poikelin <joni.poikelin@qt.io>2019-06-25 14:00:12 +0300
commit82f126599b7b087f96622b91017a11caa496389f (patch)
tree5e68ceeca9f809680cb7e7aae8f324692bc03106
parente9520ec84c95e10a6826b2289e46552a2d446895 (diff)
qmlscene: Fix setting of the default surface format
Fixes: QTBUG-76603 Change-Id: I2977117dcaf45345c14599e0b38cb4a242ee449b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--tools/qmlscene/main.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index 5c282d1d1d..a0349a05ec 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -477,6 +477,12 @@ int main(int argc, char ** argv)
options.applicationAttributes.append(Qt::AA_EnableHighDpiScaling);
} else if (!qstrcmp(arg, "--no-scaling")) {
options.applicationAttributes.append(Qt::AA_DisableHighDpiScaling);
+ } else if (!qstrcmp(arg, "--transparent")) {
+ options.transparent = true;
+ } else if (!qstrcmp(arg, "--multisample")) {
+ options.multisample = true;
+ } else if (!qstrcmp(arg, "--core-profile")) {
+ options.coreProfile = true;
} else if (!qstrcmp(arg, "--apptype")) {
if (++i >= argc)
usage();
@@ -485,6 +491,23 @@ int main(int argc, char ** argv)
}
}
+ if (qEnvironmentVariableIsSet("QMLSCENE_CORE_PROFILE"))
+ options.coreProfile = true;
+
+ // Set default surface format before creating the window
+ QSurfaceFormat surfaceFormat;
+ surfaceFormat.setStencilBufferSize(8);
+ surfaceFormat.setDepthBufferSize(24);
+ if (options.multisample)
+ surfaceFormat.setSamples(16);
+ if (options.transparent)
+ surfaceFormat.setAlphaBufferSize(8);
+ if (options.coreProfile) {
+ surfaceFormat.setVersion(4, 1);
+ surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
+ }
+ QSurfaceFormat::setDefaultFormat(surfaceFormat);
+
for (Qt::ApplicationAttribute a : qAsConst(options.applicationAttributes))
QCoreApplication::setAttribute(a);
QScopedPointer<QGuiApplication> app;
@@ -499,9 +522,6 @@ int main(int argc, char ** argv)
QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
- if (qEnvironmentVariableIsSet("QMLSCENE_CORE_PROFILE"))
- options.coreProfile = true;
-
const QStringList arguments = QCoreApplication::arguments();
for (int i = 1, size = arguments.size(); i < size; ++i) {
if (!arguments.at(i).startsWith(QLatin1Char('-'))) {
@@ -512,8 +532,6 @@ int main(int argc, char ** argv)
options.maximized = true;
else if (lowerArgument == QLatin1String("--fullscreen"))
options.fullscreen = true;
- else if (lowerArgument == QLatin1String("--transparent"))
- options.transparent = true;
else if (lowerArgument == QLatin1String("--clip"))
options.clip = true;
else if (lowerArgument == QLatin1String("--no-version-detection"))
@@ -526,10 +544,6 @@ int main(int argc, char ** argv)
options.translationFile = QLatin1String(argv[++i]);
else if (lowerArgument == QLatin1String("--resize-to-root"))
options.resizeViewToRootItem = true;
- else if (lowerArgument == QLatin1String("--multisample"))
- options.multisample = true;
- else if (lowerArgument == QLatin1String("--core-profile"))
- options.coreProfile = true;
else if (lowerArgument == QLatin1String("--verbose"))
options.verbose = true;
else if (lowerArgument == QLatin1String("-i") && i + 1 < size)
@@ -623,18 +637,6 @@ int main(int argc, char ** argv)
return -1;
}
- // Set default surface format before creating the window
- QSurfaceFormat surfaceFormat;
- if (options.multisample)
- surfaceFormat.setSamples(16);
- if (options.transparent)
- surfaceFormat.setAlphaBufferSize(8);
- if (options.coreProfile) {
- surfaceFormat.setVersion(4, 1);
- surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
- }
- QSurfaceFormat::setDefaultFormat(surfaceFormat);
-
QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(topLevel));
if (window) {
engine.setIncubationController(window->incubationController());