From 27eb53e1a1557bfb1e26109280851d7ad6de851b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 20 Feb 2026 23:47:01 +0100 Subject: [PATCH] Fix web window to maintain canvas size on start --- Source/Engine/Engine/Web/WebGame.h | 3 +++ Source/Engine/Platform/Web/WebPlatform.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/Source/Engine/Engine/Web/WebGame.h b/Source/Engine/Engine/Web/WebGame.h index f65ba4a93..366c4f5a1 100644 --- a/Source/Engine/Engine/Web/WebGame.h +++ b/Source/Engine/Engine/Web/WebGame.h @@ -12,6 +12,9 @@ /// class WebGame : public GameBase { +public: + // [GameBase] + static void InitMainWindowSettings(CreateWindowSettings& settings); }; typedef WebGame Game; diff --git a/Source/Engine/Platform/Web/WebPlatform.cpp b/Source/Engine/Platform/Web/WebPlatform.cpp index 4400d1af9..3a820f5de 100644 --- a/Source/Engine/Platform/Web/WebPlatform.cpp +++ b/Source/Engine/Platform/Web/WebPlatform.cpp @@ -13,6 +13,7 @@ #include "Engine/Platform/CPUInfo.h" #include "Engine/Platform/MemoryStats.h" #include "Engine/Profiler/ProfilerCPU.h" +#include "Engine/Engine/Web/WebGame.h" #include "Engine/Utilities/StringConverter.h" #include #include @@ -28,6 +29,16 @@ namespace double DateStart = emscripten_get_now(); }; +void WebGame::InitMainWindowSettings(CreateWindowSettings& settings) +{ + // Set window size matching the canvas item in HTML + settings.Fullscreen = false; + int width = 1, height = 1; + emscripten_get_canvas_element_size(WEB_CANVAS_ID, &width, &height); + settings.Size.X = width; + settings.Size.Y = height; +} + void WebFileSystem::GetSpecialFolderPath(const SpecialFolder type, String& result) { result = TEXT("/");