aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/pkg/dcimgui/ext.cpp
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/dcimgui/ext.cpp
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/dcimgui/ext.cpp')
-rw-r--r--vendor/libghostty-vt/pkg/dcimgui/ext.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/dcimgui/ext.cpp b/vendor/libghostty-vt/pkg/dcimgui/ext.cpp
new file mode 100644
index 00000000..b686c07f
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/dcimgui/ext.cpp
@@ -0,0 +1,53 @@
+#include "imgui.h"
+
+// This file contains custom extensions for functionality that isn't
+// properly supported by Dear Bindings yet. Namely:
+// https://github.com/dearimgui/dear_bindings/issues/55
+
+// Wrap this in a namespace to keep it separate from the C++ API
+namespace cimgui
+{
+#include "dcimgui.h"
+}
+
+extern "C"
+{
+CIMGUI_API void ImFontConfig_ImFontConfig(cimgui::ImFontConfig* self)
+{
+ static_assert(sizeof(cimgui::ImFontConfig) == sizeof(::ImFontConfig), "ImFontConfig size mismatch");
+ static_assert(alignof(cimgui::ImFontConfig) == alignof(::ImFontConfig), "ImFontConfig alignment mismatch");
+ ::ImFontConfig defaults;
+ *reinterpret_cast<::ImFontConfig*>(self) = defaults;
+}
+
+CIMGUI_API void ImGuiStyle_ImGuiStyle(cimgui::ImGuiStyle* self)
+{
+ static_assert(sizeof(cimgui::ImGuiStyle) == sizeof(::ImGuiStyle), "ImGuiStyle size mismatch");
+ static_assert(alignof(cimgui::ImGuiStyle) == alignof(::ImGuiStyle), "ImGuiStyle alignment mismatch");
+ ::ImGuiStyle defaults;
+ *reinterpret_cast<::ImGuiStyle*>(self) = defaults;
+}
+
+// Perform the OpenGL3 backend shutdown and then zero out the imgl3w
+// function pointer table. ImGui_ImplOpenGL3_Shutdown() calls
+// imgl3wShutdown() which dlcloses the GL library handles but does not
+// zero out the function pointers. A subsequent ImGui_ImplOpenGL3_Init()
+// sees the stale (non-null) pointers, skips loader re-initialization,
+// and crashes when calling through them. Zeroing the table forces the
+// next Init to reload the GL function pointers via imgl3wInit().
+#ifndef IMGUI_DISABLE
+#if __has_include("backends/imgui_impl_opengl3.h")
+#ifdef ZIGPKG_IMGUI_ENABLE_OPENGL3
+#include "backends/imgui_impl_opengl3.h"
+#include "backends/imgui_impl_opengl3_loader.h"
+
+CIMGUI_API void ImGui_ImplOpenGL3_ShutdownWithLoaderCleanup()
+{
+ ::ImGui_ImplOpenGL3_Shutdown();
+ memset(&imgl3wProcs, 0, sizeof(imgl3wProcs));
+}
+#endif // ZIGPKG_IMGUI_ENABLE_OPENGL3
+#endif // __has_include("backends/imgui_impl_opengl3.h")
+#endif // IMGUI_DISABLE
+
+}