From 972984521eb40f65359bbd106cd1dcfc0359f3cd Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Tue, 20 Jun 2023 11:29:21 +0800 Subject: [PATCH] WASM: don't ignore custom QSurfaceFormat settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, Qt would always ignore user's custom QSurfaceFormat settings and this behavior makes user have no way to control the preferred OpenGL version when running on WASM. And after reading the wasm platform plugin code, I don't see any reason why we should limit ourself to the default OpenGL version. And I've tested this patch locally, Qt still work normally if I set a newer OpenGL version. Change-Id: I0cfb831d6a722fe61cc85808a6d9e3098c73d82e Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø (cherry picked from commit 33a9cbef657d598589500d2eecea192b83f79b3c) --- src/plugins/platforms/wasm/qwasmwindow.cpp | 5 +++++ src/plugins/platforms/wasm/qwasmwindow.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index d1582d8801f..c9cc78b826c 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -139,6 +139,11 @@ QWasmWindow::~QWasmWindow() #endif } +QSurfaceFormat QWasmWindow::format() const +{ + return window()->requestedFormat(); +} + void QWasmWindow::onRestoreClicked() { window()->setWindowState(Qt::WindowNoState); diff --git a/src/plugins/platforms/wasm/qwasmwindow.h b/src/plugins/platforms/wasm/qwasmwindow.h index f191c909542..99b490b473f 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.h +++ b/src/plugins/platforms/wasm/qwasmwindow.h @@ -45,6 +45,8 @@ public: QWasmBackingStore *backingStore); ~QWasmWindow() final; + QSurfaceFormat format() const override; + void destroy(); void paint(); void setZOrder(int order);