From 440c7ad5e038835f9eda588d6211afd27b7c8cf7 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:51:33 -0500 Subject: [PATCH 1/4] fix linux build validation (#789) --- .github/workflows/build-validation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index ddb232f96..0177a2b68 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -96,8 +96,8 @@ jobs: cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release cmake --build build-cmake --config Release --parallel 10 env: - CC: gcc-10 - CXX: g++-10 + CC: gcc-12 + CXX: g++-12 - name: Upload build uses: actions/upload-artifact@v4 with: From 7fc73766ed4c636b49e2218d948100ee7782456e Mon Sep 17 00:00:00 2001 From: Archez Date: Sat, 11 Jan 2025 00:16:47 -0500 Subject: [PATCH 2/4] Move Window and Gui calls to port game loop (#787) * Move gui draw calls to be called by ports * move window manager start_frame logic to is_frame_ready * call gfx_end_frame from fast3dwindow * expose handle_events on fast3dwindow * remove dropped frame handling from gfx_pc * Add dedicated draw method to fast3d window to encapsulate all drawing logic as a LUS default --- src/graphic/Fast3D/Fast3dWindow.cpp | 32 +++++++++++++++++ src/graphic/Fast3D/Fast3dWindow.h | 5 +++ src/graphic/Fast3D/gfx_dxgi.cpp | 4 +-- src/graphic/Fast3D/gfx_metal.cpp | 4 +-- src/graphic/Fast3D/gfx_metal.h | 1 - src/graphic/Fast3D/gfx_pc.cpp | 31 +++++++--------- src/graphic/Fast3D/gfx_pc.h | 2 ++ src/graphic/Fast3D/gfx_sdl2.cpp | 4 +-- src/graphic/Fast3D/gfx_window_manager_api.h | 2 +- src/window/Window.h | 2 ++ src/window/gui/Gui.cpp | 40 ++++++++++++--------- src/window/gui/Gui.h | 5 +-- 12 files changed, 86 insertions(+), 46 deletions(-) diff --git a/src/graphic/Fast3D/Fast3dWindow.cpp b/src/graphic/Fast3D/Fast3dWindow.cpp index 44ba7a416..74960255f 100644 --- a/src/graphic/Fast3D/Fast3dWindow.cpp +++ b/src/graphic/Fast3D/Fast3dWindow.cpp @@ -152,6 +152,38 @@ void Fast3dWindow::StartFrame() { } void Fast3dWindow::EndFrame() { + gfx_end_frame(); +} + +bool Fast3dWindow::IsFrameReady() { + return mWindowManagerApi->is_frame_ready(); +} + +bool Fast3dWindow::DrawAndRunGraphicsCommands(Gfx* commands, const std::unordered_map& mtxReplacements) { + std::shared_ptr wnd = Ship::Context::GetInstance()->GetWindow(); + + // Skip dropped frames + if (!wnd->IsFrameReady()) { + return false; + } + + auto gui = wnd->GetGui(); + // Setup of the backend frames and draw initial Window and GUI menus + gui->StartDraw(); + // Setup game framebuffers to match available window space + gfx_start_frame(); + // Execute the games gfx commands + gfx_run(commands, mtxReplacements); + // Renders the game frame buffer to the final window and finishes the GUI + gui->EndDraw(); + // Finalize swap buffers + gfx_end_frame(); + + return true; +} + +void Fast3dWindow::HandleEvents() { + mWindowManagerApi->handle_events(); } void Fast3dWindow::SetCursorVisibility(bool visible) { diff --git a/src/graphic/Fast3D/Fast3dWindow.h b/src/graphic/Fast3D/Fast3dWindow.h index 86676cf9d..5e99e5630 100644 --- a/src/graphic/Fast3D/Fast3dWindow.h +++ b/src/graphic/Fast3D/Fast3dWindow.h @@ -5,6 +5,8 @@ #include "public/bridge/gfxbridge.h" #include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +union Gfx; + namespace Fast { class Fast3dWindow : public Ship::Window { public: @@ -16,6 +18,8 @@ class Fast3dWindow : public Ship::Window { void Close() override; void StartFrame() override; void EndFrame() override; + bool IsFrameReady() override; + void HandleEvents() override; void SetCursorVisibility(bool visible) override; uint32_t GetWidth() override; uint32_t GetHeight() override; @@ -46,6 +50,7 @@ class Fast3dWindow : public Ship::Window { void SetTextureFilter(FilteringMode filteringMode); void SetRendererUCode(UcodeHandlers ucode); void EnableSRGBMode(); + bool DrawAndRunGraphicsCommands(Gfx* commands, const std::unordered_map& mtxReplacements); protected: static bool KeyDown(int32_t scancode); diff --git a/src/graphic/Fast3D/gfx_dxgi.cpp b/src/graphic/Fast3D/gfx_dxgi.cpp index b607bffc5..9efba684f 100644 --- a/src/graphic/Fast3D/gfx_dxgi.cpp +++ b/src/graphic/Fast3D/gfx_dxgi.cpp @@ -664,7 +664,7 @@ static uint64_t qpc_to_100ns(uint64_t qpc) { qpc % dxgi.qpc_freq * _100NANOSECONDS_IN_SECOND / dxgi.qpc_freq; } -static bool gfx_dxgi_start_frame() { +static bool gfx_dxgi_is_frame_ready() { DXGI_FRAME_STATISTICS stats; if (dxgi.swap_chain->GetFrameStatistics(&stats) == S_OK && (stats.SyncRefreshCount != 0 || stats.SyncQPCTime.QuadPart != 0ULL)) { @@ -1058,7 +1058,7 @@ extern "C" struct GfxWindowManagerAPI gfx_dxgi_api = { gfx_dxgi_init, gfx_dxgi_is_mouse_captured, gfx_dxgi_get_dimensions, gfx_dxgi_handle_events, - gfx_dxgi_start_frame, + gfx_dxgi_is_frame_ready, gfx_dxgi_swap_buffers_begin, gfx_dxgi_swap_buffers_end, gfx_dxgi_get_time, diff --git a/src/graphic/Fast3D/gfx_metal.cpp b/src/graphic/Fast3D/gfx_metal.cpp index d8c972a70..62a1238cf 100644 --- a/src/graphic/Fast3D/gfx_metal.cpp +++ b/src/graphic/Fast3D/gfx_metal.cpp @@ -234,13 +234,11 @@ bool Metal_Init(SDL_Renderer* renderer) { static void gfx_metal_setup_screen_framebuffer(uint32_t width, uint32_t height); -void Metal_SetupFrame(SDL_Renderer* renderer) { +void Metal_NewFrame(SDL_Renderer* renderer) { int width, height; SDL_GetRendererOutputSize(renderer, &width, &height); gfx_metal_setup_screen_framebuffer(width, height); -} -void Metal_NewFrame(SDL_Renderer* renderer) { MTL::RenderPassDescriptor* current_render_pass = mctx.framebuffers[0].render_pass_descriptor; ImGui_ImplMetal_NewFrame(current_render_pass); } diff --git a/src/graphic/Fast3D/gfx_metal.h b/src/graphic/Fast3D/gfx_metal.h index c014b234e..b8cea7d78 100644 --- a/src/graphic/Fast3D/gfx_metal.h +++ b/src/graphic/Fast3D/gfx_metal.h @@ -20,7 +20,6 @@ ImTextureID gfx_metal_get_texture_by_id(int id); bool Metal_IsSupported(); bool Metal_Init(SDL_Renderer* renderer); -void Metal_SetupFrame(SDL_Renderer* renderer); void Metal_NewFrame(SDL_Renderer* renderer); void Metal_SetupFloatingFrame(); void Metal_RenderDrawData(ImDrawData* draw_data); diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index 4b6fcb3e0..87fd5964b 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -113,8 +113,6 @@ static int game_framebuffer_msaa_resolved; uint32_t gfx_msaa_level = 1; -static bool dropped_frame; - static const std::unordered_map* current_mtx_replacements; static float buf_vbo[MAX_BUFFERED * (32 * 3)]; // 3 vertices in a triangle and 32 floats per vtx @@ -4123,8 +4121,15 @@ struct GfxRenderingAPI* gfx_get_current_rendering_api() { return gfx_rapi; } -void gfx_start_frame() { +void gfx_handle_window_events() { gfx_wapi->handle_events(); +} + +bool gfx_is_frame_ready() { + return gfx_wapi->is_frame_ready(); +} + +void gfx_start_frame() { gfx_wapi->get_dimensions(&gfx_current_window_dimensions.width, &gfx_current_window_dimensions.height, &gfx_current_window_position_x, &gfx_current_window_position_y); if (gfx_current_dimensions.height == 0) { @@ -4184,20 +4189,11 @@ void gfx_start_frame() { GfxExecStack g_exec_stack = {}; void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacements) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->SetupRendererFrame(); - gfx_sp_reset(); get_pixel_depth_pending.clear(); get_pixel_depth_cached.clear(); - if (!gfx_wapi->start_frame()) { - dropped_frame = true; - Ship::Context::GetInstance()->GetWindow()->GetGui()->Draw(); - return; - } - dropped_frame = false; - current_mtx_replacements = &mtx_replacements; gfx_rapi->update_framebuffer_parameters(0, gfx_current_window_dimensions.width, @@ -4261,16 +4257,13 @@ void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacemen assert(0 && "active framebuffer was never reset back to original"); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->Draw(); - gfx_rapi->end_frame(); - gfx_wapi->swap_buffers_begin(); } void gfx_end_frame() { - if (!dropped_frame) { - gfx_rapi->finish_render(); - gfx_wapi->swap_buffers_end(); - } + gfx_rapi->end_frame(); + gfx_wapi->swap_buffers_begin(); + gfx_rapi->finish_render(); + gfx_wapi->swap_buffers_end(); } void gfx_set_target_ucode(UcodeHandlers ucode) { diff --git a/src/graphic/Fast3D/gfx_pc.h b/src/graphic/Fast3D/gfx_pc.h index 38fab091b..ef08c428b 100644 --- a/src/graphic/Fast3D/gfx_pc.h +++ b/src/graphic/Fast3D/gfx_pc.h @@ -235,6 +235,8 @@ void gfx_start_frame(); // Since this function is "exposted" to the games, it needs to take a normal Gfx void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacements); +void gfx_handle_window_events(); +bool gfx_is_frame_ready(); void gfx_end_frame(); void gfx_set_target_ucode(UcodeHandlers ucode); void gfx_set_target_fps(int); diff --git a/src/graphic/Fast3D/gfx_sdl2.cpp b/src/graphic/Fast3D/gfx_sdl2.cpp index a4027d647..228dc8ecc 100644 --- a/src/graphic/Fast3D/gfx_sdl2.cpp +++ b/src/graphic/Fast3D/gfx_sdl2.cpp @@ -600,7 +600,7 @@ static void gfx_sdl_handle_events() { } } -static bool gfx_sdl_start_frame() { +static bool gfx_sdl_is_frame_ready() { return true; } @@ -709,7 +709,7 @@ struct GfxWindowManagerAPI gfx_sdl = { gfx_sdl_init, gfx_sdl_is_mouse_captured, gfx_sdl_get_dimensions, gfx_sdl_handle_events, - gfx_sdl_start_frame, + gfx_sdl_is_frame_ready, gfx_sdl_swap_buffers_begin, gfx_sdl_swap_buffers_end, gfx_sdl_get_time, diff --git a/src/graphic/Fast3D/gfx_window_manager_api.h b/src/graphic/Fast3D/gfx_window_manager_api.h index 9fd3555db..3cc99c174 100644 --- a/src/graphic/Fast3D/gfx_window_manager_api.h +++ b/src/graphic/Fast3D/gfx_window_manager_api.h @@ -24,7 +24,7 @@ struct GfxWindowManagerAPI { bool (*is_mouse_captured)(); void (*get_dimensions)(uint32_t* width, uint32_t* height, int32_t* posX, int32_t* posY); void (*handle_events)(); - bool (*start_frame)(); + bool (*is_frame_ready)(); void (*swap_buffers_begin)(); void (*swap_buffers_end)(); double (*get_time)(); // For debug diff --git a/src/window/Window.h b/src/window/Window.h index 708b29bfe..5a1c83d17 100644 --- a/src/window/Window.h +++ b/src/window/Window.h @@ -36,6 +36,8 @@ class Window { virtual void Close() = 0; virtual void StartFrame() = 0; virtual void EndFrame() = 0; + virtual bool IsFrameReady() = 0; + virtual void HandleEvents() = 0; virtual void SetCursorVisibility(bool visible) = 0; virtual uint32_t GetWidth() = 0; virtual uint32_t GetHeight() = 0; diff --git a/src/window/gui/Gui.cpp b/src/window/gui/Gui.cpp index 281dadad6..fad42a985 100644 --- a/src/window/gui/Gui.cpp +++ b/src/window/gui/Gui.cpp @@ -566,7 +566,7 @@ void Gui::EndFrame() { ImGui::EndFrame(); } -void Gui::DrawGame() { +void Gui::CalculateGameViewport() { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); @@ -617,10 +617,25 @@ void Gui::DrawGame() { } } + ImGui::End(); +} + +void Gui::DrawGame() { + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground; + + ImGui::Begin("Main Game", nullptr, flags); + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(); + GetGameOverlay()->Draw(); - mainPos = ImGui::GetWindowPos(); - size = ImGui::GetContentRegionAvail(); + ImVec2 mainPos = ImGui::GetWindowPos(); + ImVec2 size = ImGui::GetContentRegionAvail(); ImVec2 pos = ImVec2(0, 0); if (CVarGetInteger(CVAR_LOW_RES_MODE, 0) == 1) { // N64 Mode takes priority const float sw = size.y * 320.0f / 240.0f; @@ -695,11 +710,16 @@ void Gui::CheckSaveCvars() { } } -void Gui::Draw() { +void Gui::StartDraw() { // Initialize the frame. StartFrame(); // Draw the gui menus DrawMenu(); + // Calculate the available space the game can render to + CalculateGameViewport(); +} + +void Gui::EndDraw() { // Draw the game framebuffer into ImGui DrawGame(); // End the frame @@ -710,18 +730,6 @@ void Gui::Draw() { CheckSaveCvars(); } -void Gui::SetupRendererFrame() { - switch (Context::GetInstance()->GetWindow()->GetWindowBackend()) { -#ifdef __APPLE__ - case WindowBackend::FAST3D_SDL_METAL: - Metal_SetupFrame(mImpl.Metal.Renderer); - break; -#endif - default: - break; - } -} - ImTextureID Gui::GetTextureById(int32_t id) { #ifdef ENABLE_DX11 if (Context::GetInstance()->GetWindow()->GetWindowBackend() == WindowBackend::FAST3D_DXGI_DX11) { diff --git a/src/window/gui/Gui.h b/src/window/gui/Gui.h index 10d09c865..2b017b07c 100644 --- a/src/window/gui/Gui.h +++ b/src/window/gui/Gui.h @@ -72,9 +72,9 @@ class Gui { ~Gui(); void Init(GuiWindowInitData windowImpl); - void Draw(); + void StartDraw(); + void EndDraw(); void HandleWindowEvents(WindowEvent event); - void SetupRendererFrame(); void SaveConsoleVariablesNextFrame(); bool SupportsViewports(); ImGuiID GetMainGameWindowID(); @@ -112,6 +112,7 @@ class Gui { void DrawFloatingWindows(); void DrawMenu(); void DrawGame(); + void CalculateGameViewport(); void ImGuiBackendNewFrame(); void ImGuiWMNewFrame(); From 9a974e002f84cd1fe834ee9d2fa4ccf16d899e0f Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sat, 11 Jan 2025 00:53:05 -0500 Subject: [PATCH 3/4] imgui 1.90.6 -> 1.91.6 (#788) * imgui 1.90.6 -> 1.91.6 * deal with new `ImTextureID` type in https://github.com/ocornut/imgui/commit/92b94980c69ff3d3d7f5dc30c1c19abfb72db47e `ImTextureID` was updated from `void*` to `ImU64`, which is defined as `unsigned long long` (which conflicts with some implementations of `uint64_t` that have it as `unsigned long`) * metal? * metal?? * d3d11? * change readme to see linux build fail * fix it (bump from 10 to 12) * switch back to `void*` by using a patch to modify `imconfig.h` --- cmake/dependencies/common.cmake | 8 +-- .../patches/imgui-fixes-and-config.patch | 59 +++++++++++++++++++ .../patches/sdl-gamepad-fix.patch | 17 ------ src/controller/controldeck/ControlDeck.cpp | 3 - .../ControllerDisconnectedWindow.h | 3 - .../deviceindex/ControllerReorderingWindow.h | 3 - src/debug/Console.h | 3 - src/graphic/Fast3D/gfx_direct3d11.h | 3 - src/window/gui/ConsoleWindow.cpp | 6 +- src/window/gui/ConsoleWindow.h | 3 - src/window/gui/GameOverlay.h | 3 - src/window/gui/Gui.h | 3 - src/window/gui/GuiWindow.h | 3 - src/window/gui/InputEditorWindow.h | 3 - src/window/gui/StatsWindow.cpp | 3 - 15 files changed, 66 insertions(+), 57 deletions(-) create mode 100644 cmake/dependencies/patches/imgui-fixes-and-config.patch delete mode 100644 cmake/dependencies/patches/sdl-gamepad-fix.patch diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake index 6d53277c4..21ebd54d7 100644 --- a/cmake/dependencies/common.cmake +++ b/cmake/dependencies/common.cmake @@ -9,15 +9,15 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio") endif() #=================== ImGui =================== -set(sdl_gamepad_patch_file ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies/patches/sdl-gamepad-fix.patch) +set(imgui_fixes_and_config_patch_file ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies/patches/imgui-fixes-and-config.patch) # Applies the patch or checks if it has already been applied successfully previously. Will error otherwise. -set(sdl_apply_patch_if_needed git apply ${sdl_gamepad_patch_file} ${git_hide_output} || git apply --reverse --check ${sdl_gamepad_patch_file}) +set(imgui_apply_patch_if_needed git apply ${imgui_fixes_and_config_patch_file} ${git_hide_output} || git apply --reverse --check ${imgui_fixes_and_config_patch_file}) FetchContent_Declare( ImGui GIT_REPOSITORY https://github.com/ocornut/imgui.git - GIT_TAG v1.90.6-docking - PATCH_COMMAND ${sdl_apply_patch_if_needed} + GIT_TAG v1.91.6-docking + PATCH_COMMAND ${imgui_apply_patch_if_needed} ) FetchContent_MakeAvailable(ImGui) list(APPEND ADDITIONAL_LIB_INCLUDES ${imgui_SOURCE_DIR} ${imgui_SOURCE_DIR}/backends) diff --git a/cmake/dependencies/patches/imgui-fixes-and-config.patch b/cmake/dependencies/patches/imgui-fixes-and-config.patch new file mode 100644 index 000000000..baba0add2 --- /dev/null +++ b/cmake/dependencies/patches/imgui-fixes-and-config.patch @@ -0,0 +1,59 @@ +From 7cd9b89560b66b992db9fd0e620c2d28ad9a9645 Mon Sep 17 00:00:00 2001 +From: briaguya <70942617+briaguya-ai@users.noreply.github.com> +Date: Fri, 10 Jan 2025 04:48:50 -0500 +Subject: [PATCH 1/2] sdl gamepad fix + +--- + backends/imgui_impl_sdl2.cpp | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/backends/imgui_impl_sdl2.cpp b/backends/imgui_impl_sdl2.cpp +index 23f12796..a7fef045 100644 +--- a/backends/imgui_impl_sdl2.cpp ++++ b/backends/imgui_impl_sdl2.cpp +@@ -816,9 +816,6 @@ static void ImGui_ImplSDL2_UpdateGamepads() + bd->WantUpdateGamepadsList = false; + } + +- // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs. +- if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) +- return; + io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; + if (bd->Gamepads.Size == 0) + return; +-- +2.47.1 + + +From 635226a311071e80c22e0c58c9cb5c9d950d2e17 Mon Sep 17 00:00:00 2001 +From: briaguya <70942617+briaguya-ai@users.noreply.github.com> +Date: Fri, 10 Jan 2025 04:52:36 -0500 +Subject: [PATCH 2/2] add config stuff + +--- + imconfig.h | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/imconfig.h b/imconfig.h +index 8f8bc3b9..cc578e3f 100644 +--- a/imconfig.h ++++ b/imconfig.h +@@ -111,7 +111,7 @@ + operator MyVec4() const { return MyVec4(x,y,z,w); } + */ + //---- ...Or use Dear ImGui's own very basic math operators. +-//#define IMGUI_DEFINE_MATH_OPERATORS ++#define IMGUI_DEFINE_MATH_OPERATORS + + //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. + // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). +@@ -140,3 +140,6 @@ namespace ImGui + void MyFunction(const char* name, MyMatrix44* mtx); + } + */ ++ ++// handle https://github.com/ocornut/imgui/issues/1641 the old way ++#define ImTextureID void* +-- +2.47.1 + diff --git a/cmake/dependencies/patches/sdl-gamepad-fix.patch b/cmake/dependencies/patches/sdl-gamepad-fix.patch deleted file mode 100644 index b56e4972a..000000000 --- a/cmake/dependencies/patches/sdl-gamepad-fix.patch +++ /dev/null @@ -1,17 +0,0 @@ - backends/imgui_impl_sdl2.cpp | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/backends/imgui_impl_sdl2.cpp b/backends/imgui_impl_sdl2.cpp -index 569b01d1..c2f84dca 100644 ---- a/backends/imgui_impl_sdl2.cpp -+++ b/backends/imgui_impl_sdl2.cpp -@@ -770,9 +770,6 @@ static void ImGui_ImplSDL2_UpdateGamepads() - bd->WantUpdateGamepadsList = false; - } - -- // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs. -- if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) -- return; - io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; - if (bd->Gamepads.Size == 0) - return; diff --git a/src/controller/controldeck/ControlDeck.cpp b/src/controller/controldeck/ControlDeck.cpp index 4b7416433..6a679bf05 100644 --- a/src/controller/controldeck/ControlDeck.cpp +++ b/src/controller/controldeck/ControlDeck.cpp @@ -4,9 +4,6 @@ #include "controller/controldevice/controller/Controller.h" #include "utils/StringHelper.h" #include "public/bridge/consolevariablebridge.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include "controller/deviceindex/ShipDeviceIndexMappingManager.h" #include "controller/controldevice/controller/mapping/mouse/WheelHandler.h" diff --git a/src/controller/deviceindex/ControllerDisconnectedWindow.h b/src/controller/deviceindex/ControllerDisconnectedWindow.h index 29de503e3..2c2bee341 100644 --- a/src/controller/deviceindex/ControllerDisconnectedWindow.h +++ b/src/controller/deviceindex/ControllerDisconnectedWindow.h @@ -2,9 +2,6 @@ #include "stdint.h" #include "window/gui/GuiWindow.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include #include diff --git a/src/controller/deviceindex/ControllerReorderingWindow.h b/src/controller/deviceindex/ControllerReorderingWindow.h index f172cda3b..c62a48568 100644 --- a/src/controller/deviceindex/ControllerReorderingWindow.h +++ b/src/controller/deviceindex/ControllerReorderingWindow.h @@ -2,9 +2,6 @@ #include "stdint.h" #include "window/gui/GuiWindow.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include #include diff --git a/src/debug/Console.h b/src/debug/Console.h index 22f762e17..8bb52947b 100644 --- a/src/debug/Console.h +++ b/src/debug/Console.h @@ -6,9 +6,6 @@ #include #include #include -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include namespace Ship { diff --git a/src/graphic/Fast3D/gfx_direct3d11.h b/src/graphic/Fast3D/gfx_direct3d11.h index d1eea89f4..e3771ef1f 100644 --- a/src/graphic/Fast3D/gfx_direct3d11.h +++ b/src/graphic/Fast3D/gfx_direct3d11.h @@ -4,9 +4,6 @@ #define GFX_DIRECT3D11_H #include "gfx_rendering_api.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include extern struct GfxRenderingAPI gfx_direct3d11_api; diff --git a/src/window/gui/ConsoleWindow.cpp b/src/window/gui/ConsoleWindow.cpp index f76055083..b96a0f9c4 100644 --- a/src/window/gui/ConsoleWindow.cpp +++ b/src/window/gui/ConsoleWindow.cpp @@ -387,12 +387,12 @@ void ConsoleWindow::DrawElement() { ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(.3f, .3f, .3f, 1.0f)); if (ImGui::BeginTable("History", 1)) { - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) { + if (ImGui::IsKeyPressed(ImGuiKey_DownArrow)) { if (mSelectedId < (int32_t)mLog.size() - 1) { ++mSelectedId; } } - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) { + if (ImGui::IsKeyPressed(ImGuiKey_UpArrow)) { if (mSelectedId > 0) { --mSelectedId; } @@ -415,7 +415,7 @@ void ConsoleWindow::DrawElement() { std::find(mSelectedEntries.begin(), mSelectedEntries.end(), i) != mSelectedEntries.end(); ImGui::PushStyleColor(ImGuiCol_Text, mPriorityColours[line.Priority]); if (ImGui::Selectable(id.c_str(), isSelected)) { - if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !isSelected) { + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && !isSelected) { mSelectedEntries.push_back(i); } else { diff --git a/src/window/gui/ConsoleWindow.h b/src/window/gui/ConsoleWindow.h index 0bf38b999..f9ab21065 100644 --- a/src/window/gui/ConsoleWindow.h +++ b/src/window/gui/ConsoleWindow.h @@ -7,9 +7,6 @@ #include "window/gui/GuiWindow.h" #include "debug/Console.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include diff --git a/src/window/gui/GameOverlay.h b/src/window/gui/GameOverlay.h index 34f28927d..1f1155b26 100644 --- a/src/window/gui/GameOverlay.h +++ b/src/window/gui/GameOverlay.h @@ -4,9 +4,6 @@ #include #include "debug/Console.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include #include "resource/ResourceManager.h" diff --git a/src/window/gui/Gui.h b/src/window/gui/Gui.h index 2b017b07c..2c4206c5b 100644 --- a/src/window/gui/Gui.h +++ b/src/window/gui/Gui.h @@ -1,9 +1,6 @@ #pragma once #ifdef __cplusplus -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include diff --git a/src/window/gui/GuiWindow.h b/src/window/gui/GuiWindow.h index 60ed293da..a1bac96c6 100644 --- a/src/window/gui/GuiWindow.h +++ b/src/window/gui/GuiWindow.h @@ -1,9 +1,6 @@ #pragma once #include -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include #include "window/gui/GuiElement.h" diff --git a/src/window/gui/InputEditorWindow.h b/src/window/gui/InputEditorWindow.h index 29f515232..2f408c7d2 100644 --- a/src/window/gui/InputEditorWindow.h +++ b/src/window/gui/InputEditorWindow.h @@ -2,9 +2,6 @@ #include "stdint.h" #include "window/gui/GuiWindow.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include #include diff --git a/src/window/gui/StatsWindow.cpp b/src/window/gui/StatsWindow.cpp index 0723ce224..7b169d13c 100644 --- a/src/window/gui/StatsWindow.cpp +++ b/src/window/gui/StatsWindow.cpp @@ -1,7 +1,4 @@ #include "StatsWindow.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include "public/bridge/consolevariablebridge.h" #include "spdlog/spdlog.h" From 31df12cdb7b877f4f0790dcc216a2c9d3823d58b Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sat, 11 Jan 2025 20:13:25 -0500 Subject: [PATCH 4/4] Fix delete in texture (#781) --- src/resource/type/Texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource/type/Texture.cpp b/src/resource/type/Texture.cpp index bc90d8ddc..2e522b652 100644 --- a/src/resource/type/Texture.cpp +++ b/src/resource/type/Texture.cpp @@ -14,7 +14,7 @@ size_t Texture::GetPointerSize() { Texture::~Texture() { if (ImageData != nullptr) { - delete ImageData; + delete[] ImageData; } } } // namespace Fast