From 82f126599b7b087f96622b91017a11caa496389f Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Mon, 24 Jun 2019 14:26:07 +0300 Subject: qmlscene: Fix setting of the default surface format Fixes: QTBUG-76603 Change-Id: I2977117dcaf45345c14599e0b38cb4a242ee449b Reviewed-by: Ulf Hermann --- tools/qmlscene/main.cpp | 44 +++++++++++++++++++++++--------------------- 1 file 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 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 window(qobject_cast(topLevel)); if (window) { engine.setIncubationController(window->incubationController()); -- cgit v1.2.3