mirror of
https://github.com/ocornut/imgui.git
synced 2026-02-01 03:30:06 +00:00
Internals: Split some code out of NewFrame() into an Initialize() function.
This commit is contained in:
parent
5938f1ba61
commit
419b22a487
2 changed files with 16 additions and 11 deletions
26
imgui.cpp
26
imgui.cpp
|
|
@ -2125,16 +2125,9 @@ void ImGui::NewFrame()
|
|||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f); // Invalid style setting
|
||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f); // Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)
|
||||
|
||||
// Initialize on first frame
|
||||
if (!g.Initialized)
|
||||
{
|
||||
// Initialize on first frame
|
||||
g.LogClipboard = (ImGuiTextBuffer*)ImGui::MemAlloc(sizeof(ImGuiTextBuffer));
|
||||
IM_PLACEMENT_NEW(g.LogClipboard) ImGuiTextBuffer();
|
||||
|
||||
IM_ASSERT(g.Settings.empty());
|
||||
LoadIniSettingsFromDisk(g.IO.IniFilename);
|
||||
g.Initialized = true;
|
||||
}
|
||||
ImGui::Initialize();
|
||||
|
||||
SetCurrentFont(GetDefaultFont());
|
||||
IM_ASSERT(g.Font->IsLoaded());
|
||||
|
|
@ -2350,7 +2343,18 @@ void ImGui::NewFrame()
|
|||
ImGui::Begin("Debug");
|
||||
}
|
||||
|
||||
// NB: behavior of ImGui after Shutdown() is not tested/guaranteed at the moment. This function is merely here to free heap allocations.
|
||||
void ImGui::Initialize()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.LogClipboard = (ImGuiTextBuffer*)ImGui::MemAlloc(sizeof(ImGuiTextBuffer));
|
||||
IM_PLACEMENT_NEW(g.LogClipboard) ImGuiTextBuffer();
|
||||
|
||||
IM_ASSERT(g.Settings.empty());
|
||||
LoadIniSettingsFromDisk(g.IO.IniFilename);
|
||||
g.Initialized = true;
|
||||
}
|
||||
|
||||
// This function is merely here to free heap allocations.
|
||||
void ImGui::Shutdown()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
@ -2359,7 +2363,7 @@ void ImGui::Shutdown()
|
|||
if (g.IO.Fonts) // Testing for NULL to allow user to NULLify in case of running Shutdown() on multiple contexts. Bit hacky.
|
||||
g.IO.Fonts->Clear();
|
||||
|
||||
// Cleanup of other data are conditional on actually having used ImGui.
|
||||
// Cleanup of other data are conditional on actually having initialize ImGui.
|
||||
if (!g.Initialized)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue