From fbe02673ea71e792be18b8fcc6173d069466dd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Sep 2023 12:33:27 +0200 Subject: [PATCH] Platform: properly save device pixel ration in the non-GL code path. Bugs, bugs everywhere. The EmscriptenApplication is cursed. --- src/Magnum/Platform/EmscriptenApplication.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Magnum/Platform/EmscriptenApplication.cpp b/src/Magnum/Platform/EmscriptenApplication.cpp index 958813a8a..eb4927c08 100644 --- a/src/Magnum/Platform/EmscriptenApplication.cpp +++ b/src/Magnum/Platform/EmscriptenApplication.cpp @@ -292,6 +292,12 @@ bool EmscriptenApplication::tryCreate(const Configuration& configuration) { std::ostream* verbose = _verboseLog ? Debug::output() : nullptr; + /* Fetch device pixel ratio. Together with DPI scaling (which is 1.0 by + default) this will define framebuffer size. See class docs for why is it + done like that. */ + _devicePixelRatio = Vector2{Float(emscripten_get_device_pixel_ratio())}; + Debug{verbose} << "Platform::EmscriptenApplication: device pixel ratio" << _devicePixelRatio.x(); + _canvasTarget = canvasId(); /* Get CSS canvas size and cache it. This is used later to detect canvas