From b99886095b4a0437072764cc51ea186f79552f49 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Wed, 23 Oct 2024 02:41:16 +1100 Subject: [PATCH] fix: fix all Windows warnings so apps will compile with /WX --- docs/quickstart.mdx | 5 ----- docs/windows.mdx | 13 +------------ .../thermion_flutter/windows/backing_window.cpp | 2 +- .../windows/thermion_flutter_plugin.cpp | 12 +++++++----- .../windows/thermion_flutter_plugin.h | 2 +- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 5db09ae4..1ab3c6e7 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -39,11 +39,6 @@ and change the minimum deployment target to 13.0: - -See the [/windows](/windows) page for steps needed to build on Windows. - - - 2. Add a folder containing your assets (glTF model + skybox ktx) to your `pubspec.yaml` asset list ```yaml diff --git a/docs/windows.mdx b/docs/windows.mdx index 4e00cbd9..e53944e7 100644 --- a/docs/windows.mdx +++ b/docs/windows.mdx @@ -1,17 +1,6 @@ ## Windows -## CMakeLists - -You will need to disable the `/WX` compiler flag. - -In your project, open the `windows/CMakeList.txt` file and find the following line: - -`target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")` - -Delete the `/WX`: - -`target_compile_options(${TARGET} PRIVATE /W4 /wd"4100")` - +If you're not a Thermion developer, you can ignore this. ## ANGLE build (not currently working) To support embedding GPU textures in Flutter (rather than copying to a CPU pixel buffer on every frame), we need to build a slightly customized version of Filament that uses GLES on Windows (rather than the default, which uses OpenGL). diff --git a/thermion_flutter/thermion_flutter/windows/backing_window.cpp b/thermion_flutter/thermion_flutter/windows/backing_window.cpp index 8c3dee50..bc08944b 100644 --- a/thermion_flutter/thermion_flutter/windows/backing_window.cpp +++ b/thermion_flutter/thermion_flutter/windows/backing_window.cpp @@ -326,7 +326,7 @@ BackingWindow::BackingWindow(flutter::PluginRegistrarWindows *pluginRegistrar, ::SetWindowLong(_windowHandle, GWL_STYLE, style); ::SetWindowLongPtr(_windowHandle, GWLP_USERDATA, - reinterpret_cast(_flutterRootWindow)); + reinterpret_cast(_flutterRootWindow)); RECT flutterViewRect; ::GetWindowRect(_flutterViewWindow, &flutterViewRect); diff --git a/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.cpp b/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.cpp index 251b9836..1f6e5cbd 100644 --- a/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.cpp +++ b/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.cpp @@ -81,11 +81,13 @@ ResourceBuffer ThermionFlutterPlugin::loadResource(const char *name) { name_str = name_str.substr(8); } + int size_needed = MultiByteToWideChar(CP_UTF8, 0, name_str.c_str(), -1, nullptr, 0); + std::wstring assetPath(size_needed, 0); + MultiByteToWideChar(CP_UTF8, 0, name_str.c_str(), -1, &assetPath[0], size_needed); + TCHAR pBuf[512]; size_t len = sizeof(pBuf); - int bytes = GetModuleFileName(NULL, pBuf, static_cast(len)); - std::wstring_convert> converter; - std::wstring assetPath = converter.from_bytes(name_str.c_str()); + GetModuleFileName(NULL, pBuf, static_cast(len)); std::wstring exePathBuf(pBuf); std::filesystem::path exePath(exePathBuf); @@ -108,8 +110,8 @@ ResourceBuffer ThermionFlutterPlugin::loadResource(const char *name) { is.seekg(0, std::ios::beg); is.read(buffer, length); is.close(); - auto id = _resources.size(); - auto rb = ResourceBuffer(buffer, length, id); + int32_t id = static_cast(_resources.size()); + auto rb = ResourceBuffer(buffer, static_cast(length), id); _resources.emplace(id, rb); std::wcout << "Loaded resource of length " << length << " from path " diff --git a/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.h b/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.h index 74bf9839..4cb0a645 100644 --- a/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.h +++ b/thermion_flutter/thermion_flutter/windows/thermion_flutter_plugin.h @@ -45,7 +45,7 @@ public: flutter::PluginRegistrarWindows *_pluginRegistrar; flutter::TextureRegistrar *_textureRegistrar; std::unique_ptr> _channel; - std::map _resources; + std::map _resources; void CreateTexture( const flutter::MethodCall &methodCall,