MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / NewFrame

Method NewFrame

engine/3rdparty/imgui/imgui.cpp:4323–4538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4321}
4322
4323void ImGui::NewFrame()
4324{
4325 IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
4326 ImGuiContext& g = *GImGui;
4327
4328 // Remove pending delete hooks before frame start.
4329 // This deferred removal avoid issues of removal while iterating the hook vector
4330 for (int n = g.Hooks.Size - 1; n >= 0; n--)
4331 if (g.Hooks[n].Type == ImGuiContextHookType_PendingRemoval_)
4332 g.Hooks.erase(&g.Hooks[n]);
4333
4334 CallContextHooks(&g, ImGuiContextHookType_NewFramePre);
4335
4336 // Check and assert for various common IO and Configuration mistakes
4337 g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame;
4338 ErrorCheckNewFrameSanityChecks();
4339 g.ConfigFlagsCurrFrame = g.IO.ConfigFlags;
4340
4341 // Load settings on first frame, save settings when modified (after a delay)
4342 UpdateSettings();
4343
4344 g.Time += g.IO.DeltaTime;
4345 g.WithinFrameScope = true;
4346 g.FrameCount += 1;
4347 g.TooltipOverrideCount = 0;
4348 g.WindowsActiveCount = 0;
4349 g.MenusIdSubmittedThisFrame.resize(0);
4350
4351 // Calculate frame-rate for the user, as a purely luxurious feature
4352 g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
4353 g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime;
4354 g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
4355 g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame));
4356 g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX;
4357
4358 UpdateViewportsNewFrame();
4359
4360 // Setup current font and draw list shared data
4361 // FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
4362 g.IO.Fonts->Locked = true;
4363 SetCurrentFont(GetDefaultFont());
4364 IM_ASSERT(g.Font->IsLoaded());
4365 ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
4366 for (int n = 0; n < g.Viewports.Size; n++)
4367 virtual_space.Add(g.Viewports[n]->GetMainRect());
4368 g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4();
4369 g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
4370 g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError);
4371 g.DrawListSharedData.InitialFlags = ImDrawListFlags_None;
4372 if (g.Style.AntiAliasedLines)
4373 g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines;
4374 if (g.Style.AntiAliasedLinesUseTex && !(g.Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines))
4375 g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLinesUseTex;
4376 if (g.Style.AntiAliasedFill)
4377 g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill;
4378 if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
4379 g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
4380

Callers

nothing calls this directly

Calls 13

ImMinFunction · 0.85
GetDefaultFontFunction · 0.85
ImMaxFunction · 0.85
ImVec2Function · 0.85
IsLoadedMethod · 0.80
GetMainRectMethod · 0.80
ToVec4Method · 0.80
eraseMethod · 0.45
resizeMethod · 0.45
AddMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected