| 4498 | } |
| 4499 | |
| 4500 | void ImGui::NewFrame() |
| 4501 | { |
| 4502 | IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); |
| 4503 | ImGuiContext& g = *GImGui; |
| 4504 | |
| 4505 | // Remove pending delete hooks before frame start. |
| 4506 | // This deferred removal avoid issues of removal while iterating the hook vector |
| 4507 | for (int n = g.Hooks.Size - 1; n >= 0; n--) |
| 4508 | if (g.Hooks[n].Type == ImGuiContextHookType_PendingRemoval_) |
| 4509 | g.Hooks.erase(&g.Hooks[n]); |
| 4510 | |
| 4511 | CallContextHooks(&g, ImGuiContextHookType_NewFramePre); |
| 4512 | |
| 4513 | // Check and assert for various common IO and Configuration mistakes |
| 4514 | ErrorCheckNewFrameSanityChecks(); |
| 4515 | |
| 4516 | // Load settings on first frame, save settings when modified (after a delay) |
| 4517 | UpdateSettings(); |
| 4518 | |
| 4519 | g.Time += g.IO.DeltaTime; |
| 4520 | g.WithinFrameScope = true; |
| 4521 | g.FrameCount += 1; |
| 4522 | g.TooltipOverrideCount = 0; |
| 4523 | g.WindowsActiveCount = 0; |
| 4524 | g.MenusIdSubmittedThisFrame.resize(0); |
| 4525 | |
| 4526 | // Calculate frame-rate for the user, as a purely luxurious feature |
| 4527 | g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; |
| 4528 | g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; |
| 4529 | g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); |
| 4530 | g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame)); |
| 4531 | g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX; |
| 4532 | |
| 4533 | // Process input queue (trickle as many events as possible), turn events into writes to IO structure |
| 4534 | g.InputEventsTrail.resize(0); |
| 4535 | UpdateInputEvents(g.IO.ConfigInputTrickleEventQueue); |
| 4536 | |
| 4537 | // Update viewports (after processing input queue, so io.MouseHoveredViewport is set) |
| 4538 | UpdateViewportsNewFrame(); |
| 4539 | |
| 4540 | // Setup current font and draw list shared data |
| 4541 | g.IO.Fonts->Locked = true; |
| 4542 | SetCurrentFont(GetDefaultFont()); |
| 4543 | IM_ASSERT(g.Font->IsLoaded()); |
| 4544 | ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); |
| 4545 | for (ImGuiViewportP* viewport : g.Viewports) |
| 4546 | virtual_space.Add(viewport->GetMainRect()); |
| 4547 | g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4(); |
| 4548 | g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol; |
| 4549 | g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError); |
| 4550 | g.DrawListSharedData.InitialFlags = ImDrawListFlags_None; |
| 4551 | if (g.Style.AntiAliasedLines) |
| 4552 | g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines; |
| 4553 | if (g.Style.AntiAliasedLinesUseTex && !(g.Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines)) |
| 4554 | g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLinesUseTex; |
| 4555 | if (g.Style.AntiAliasedFill) |
| 4556 | g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill; |
| 4557 | if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) |
nothing calls this directly
no test coverage detected