diff --git a/ImGui/imgui_impl_platform.cpp b/ImGui/imgui_impl_platform.cpp index a46a43e3..74546747 100644 --- a/ImGui/imgui_impl_platform.cpp +++ b/ImGui/imgui_impl_platform.cpp @@ -9,6 +9,8 @@ #include "Platform/CrossPlatform/Macros.h" #include "Platform/CrossPlatform/GraphicsDeviceInterface.h" +#include "Platform/External/glfw/include/GLFW/glfw3.h" + using namespace platform; using namespace crossplatform; @@ -35,6 +37,43 @@ TextureHash MakeTextureHash(TextureCreate *tc) return hash; } +// GLFW data +enum GlfwClientApi +{ + GlfwClientApi_Unknown, + GlfwClientApi_OpenGL, + GlfwClientApi_Vulkan +}; + +struct ImGui_ImplGlfw_Data +{ + GLFWwindow *Window; + GlfwClientApi ClientApi; + double Time; + GLFWwindow *MouseWindow; + GLFWcursor *MouseCursors[ImGuiMouseCursor_COUNT]; + ImVec2 LastValidMousePos; + GLFWwindow *KeyOwnerWindows[GLFW_KEY_LAST]; + bool InstalledCallbacks; + bool CallbacksChainForAllWindows; + bool WantUpdateMonitors; +#ifdef _WIN32 + WNDPROC GlfwWndProc; +#endif + + // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. + GLFWwindowfocusfun PrevUserCallbackWindowFocus; + GLFWcursorposfun PrevUserCallbackCursorPos; + GLFWcursorenterfun PrevUserCallbackCursorEnter; + GLFWmousebuttonfun PrevUserCallbackMousebutton; + GLFWscrollfun PrevUserCallbackScroll; + GLFWkeyfun PrevUserCallbackKey; + GLFWcharfun PrevUserCallbackChar; + GLFWmonitorfun PrevUserCallbackMonitor; + + ImGui_ImplGlfw_Data() { memset((void *)this, 0, sizeof(*this)); } +}; + // Platform data struct ImGui_ImplPlatform_Data { @@ -465,6 +504,13 @@ void ImGui_ImplPlatform_RenderDrawData(GraphicsDeviceContext &deviceContext,ImDr renderPlatform->EndEvent(deviceContext); } +void ImGui_ImplPlatform_SetUpdateMonitors() +{ + ImGui_ImplGlfw_Data *bd = ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data *)ImGui::GetIO().BackendPlatformUserData : nullptr; + if (bd) + bd->WantUpdateMonitors = true; +} + static void ImGui_ImplPlatform_CreateFontsTexture() { // Build texture atlas diff --git a/ImGui/imgui_impl_platform.h b/ImGui/imgui_impl_platform.h index 08843da0..eb55b3e0 100644 --- a/ImGui/imgui_impl_platform.h +++ b/ImGui/imgui_impl_platform.h @@ -43,15 +43,17 @@ struct ImGui_ImplPlatform_TextureView //! Initialize the Platform implementation. If hosted is set to true, this will also fill in ImGuiPlatformIO, e.g. if imgui is hosted //! in a game engine etc instead of needing Win32 behaviour etc. -IMGUI_IMPL_API bool ImGui_ImplPlatform_Init(platform::crossplatform::RenderPlatform* r,bool hosted=false); -IMGUI_IMPL_API void ImGui_ImplPlatform_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplPlatform_NewFrame(bool in3d=false, int ui_pixel_width=400, int ui_pixel_height=300,const float *menupos=nullptr, float az=0.0f, float tilt=0.0f,float width_m=2.0f); +IMGUI_IMPL_API bool ImGui_ImplPlatform_Init(platform::crossplatform::RenderPlatform* r,bool hosted=false); +IMGUI_IMPL_API void ImGui_ImplPlatform_Shutdown(); +IMGUI_IMPL_API void ImGui_ImplPlatform_NewFrame(bool in3d=false, int ui_pixel_width=400, int ui_pixel_height=300,const float *menupos=nullptr, float az=0.0f, float tilt=0.0f,float width_m=2.0f); IMGUI_IMPL_API void ImGui_ImplPlatform_Win32_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplPlatform_RenderDrawData(platform::crossplatform::GraphicsDeviceContext& deviceContext, ImDrawData* draw_data); +IMGUI_IMPL_API void ImGui_ImplPlatform_RenderDrawData(platform::crossplatform::GraphicsDeviceContext& deviceContext, ImDrawData* draw_data); + +IMGUI_IMPL_API void ImGui_ImplPlatform_SetUpdateMonitors(); // Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API void ImGui_ImplPlatform_InvalidateDeviceObjects(); -IMGUI_IMPL_API bool ImGui_ImplPlatform_CreateDeviceObjects(); +IMGUI_IMPL_API void ImGui_ImplPlatform_InvalidateDeviceObjects(); +IMGUI_IMPL_API bool ImGui_ImplPlatform_CreateDeviceObjects(); IMGUI_IMPL_API void ImGui_ImplPlatform_RecompileShaders(); IMGUI_IMPL_API void ImGui_ImplPlatform_LoadShaders();