pkg/dcimgui: only add the OpenGL3 shutdown helper if backend enabled

This commit is contained in:
Mitchell Hashimoto
2026-02-26 06:56:16 -08:00
parent 74ba971eba
commit de4ee288f5
2 changed files with 7 additions and 2 deletions

View File

@@ -56,6 +56,9 @@ pub fn build(b: *std.Build) !void {
if (freetype) try flags.appendSlice(b.allocator, &.{
"-DIMGUI_ENABLE_FREETYPE=1",
});
if (backend_opengl3) try flags.appendSlice(b.allocator, &.{
"-DZIGPKG_IMGUI_ENABLE_OPENGL3=1",
});
if (target.result.os.tag == .windows) {
try flags.appendSlice(b.allocator, &.{
"-DIMGUI_IMPL_API=extern\t\"C\"\t__declspec(dllexport)",

View File

@@ -37,6 +37,7 @@ CIMGUI_API void ImGuiStyle_ImGuiStyle(cimgui::ImGuiStyle* self)
// 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"
@@ -45,7 +46,8 @@ CIMGUI_API void ImGui_ImplOpenGL3_ShutdownWithLoaderCleanup()
::ImGui_ImplOpenGL3_Shutdown();
memset(&imgl3wProcs, 0, sizeof(imgl3wProcs));
}
#endif
#endif
#endif // ZIGPKG_IMGUI_ENABLE_OPENGL3
#endif // __has_include("backends/imgui_impl_opengl3.h")
#endif // IMGUI_DISABLE
}