From aaa23194c54b94be2921c830f76c97d539f4ffa4 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 22 May 2024 15:14:43 +0200 Subject: [PATCH] provide imgui allocator to plugins --- src/main_screen.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main_screen.cpp b/src/main_screen.cpp index 12488928..1c0ecf35 100644 --- a/src/main_screen.cpp +++ b/src/main_screen.cpp @@ -73,7 +73,19 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, Theme& theme_, std::string save_ // TODO: pm? // graphics - g_provideInstance("ImGuiContext", ImGui::GetVersion(), "host", ImGui::GetCurrentContext()); + g_provideInstance("ImGuiContext", ImGui::GetVersion(), "host", ImGui::GetCurrentContext()); + { + ImGuiMemAllocFunc alloc_func = nullptr; + ImGuiMemFreeFunc free_func = nullptr; + void* user_data = nullptr; + ImGui::GetAllocatorFunctions(&alloc_func, &free_func, &user_data); + + // function pointers are funky + g_provideInstance("ImGuiMemAllocFunc", ImGui::GetVersion(), "host", reinterpret_cast(alloc_func)); + g_provideInstance("ImGuiMemFreeFunc", ImGui::GetVersion(), "host", reinterpret_cast(free_func)); + g_provideInstance("ImGuiMemUserData", ImGui::GetVersion(), "host", user_data); + } + g_provideInstance("TextureUploaderI", "host", &sdlrtu); }