From 3478e3a708515cf9f58f53adcee1c1bfa492f428 Mon Sep 17 00:00:00 2001 From: Jim Tilander Date: Sat, 31 Jan 2015 21:55:19 -0800 Subject: [PATCH] Enabled us to create the internal state on client side allocated memory, e.g. a heap --- imgui.cpp | 10 +++++++++- imgui.h | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 01d81ec4..ec19efe8 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1609,8 +1609,16 @@ void* ImGui::GetInternalState() return GImGui; } -void ImGui::SetInternalState(void* state) +unsigned ImGui::GetInternalStateSize() { + return sizeof(ImGuiState); +} + +void ImGui::SetInternalState(void* state, bool construct) +{ + if( construct ) + new (state) ImGuiState; + GImGui = (ImGuiState*)state; } diff --git a/imgui.h b/imgui.h index 7110bd77..4b5e0526 100644 --- a/imgui.h +++ b/imgui.h @@ -144,7 +144,8 @@ namespace ImGui { // Main IMGUI_API void* GetInternalState(); - IMGUI_API void SetInternalState(void* state); + IMGUI_API unsigned GetInternalStateSize(); + IMGUI_API void SetInternalState(void* state, bool construct = false); IMGUI_API ImGuiIO& GetIO(); IMGUI_API ImGuiStyle& GetStyle(); IMGUI_API void NewFrame();