Add DemoMarker() function to formalize access for other demos than imgui_demo.cpp (#9261, #3689)

This commit is contained in:
ocornut
2026-02-25 19:25:57 +01:00
parent dd5c604768
commit 8a15a1064d
3 changed files with 20 additions and 6 deletions

View File

@@ -4293,6 +4293,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
SettingsLoaded = false;
SettingsDirtyTimer = 0.0f;
HookIdNext = 0;
DemoMarkerCallback = NULL;
memset(LocalizationTable, 0, sizeof(LocalizationTable));
@@ -5062,6 +5063,13 @@ void ImGui::MemFree(void* ptr)
return (*GImAllocatorFreeFunc)(ptr, GImAllocatorUserData);
}
void ImGui::DemoMarker(const char* file, int line, const char* section)
{
ImGuiContext& g = *GImGui;
if (g.DemoMarkerCallback != NULL)
g.DemoMarkerCallback(file, line, section);
}
// We record the number of allocation in recent frames, as a way to audit/sanitize our guiding principles of "no allocations on idle/repeating frames"
void ImGui::DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr, size_t size)
{