| 5681 | } |
| 5682 | |
| 5683 | void ImGui::NewFrame() |
| 5684 | { |
| 5685 | IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); |
| 5686 | ImGuiContext& g = *GImGui; |
| 5687 | |
| 5688 | // Remove pending delete hooks before frame start. |
| 5689 | // This deferred removal avoid issues of removal while iterating the hook vector |
| 5690 | for (int n = g.Hooks.Size - 1; n >= 0; n--) |
| 5691 | if (g.Hooks[n].Type == ImGuiContextHookType_PendingRemoval_) |
| 5692 | g.Hooks.erase(&g.Hooks[n]); |
| 5693 | |
| 5694 | CallContextHooks(&g, ImGuiContextHookType_NewFramePre); |
| 5695 | |
| 5696 | // Check and assert for various common IO and Configuration mistakes |
| 5697 | g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame; |
| 5698 | ErrorCheckNewFrameSanityChecks(); |
| 5699 | g.ConfigFlagsCurrFrame = g.IO.ConfigFlags; |
| 5700 | |
| 5701 | // Load settings on first frame, save settings when modified (after a delay) |
| 5702 | UpdateSettings(); |
| 5703 | |
| 5704 | g.Time += g.IO.DeltaTime; |
| 5705 | g.FrameCount += 1; |
| 5706 | g.TooltipOverrideCount = 0; |
| 5707 | g.WindowsActiveCount = 0; |
| 5708 | g.MenusIdSubmittedThisFrame.resize(0); |
| 5709 | |
| 5710 | // Calculate frame-rate for the user, as a purely luxurious feature |
| 5711 | g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; |
| 5712 | g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; |
| 5713 | g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_COUNTOF(g.FramerateSecPerFrame); |
| 5714 | g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_COUNTOF(g.FramerateSecPerFrame)); |
| 5715 | g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX; |
| 5716 | |
| 5717 | // Process input queue (trickle as many events as possible), turn events into writes to IO structure |
| 5718 | g.InputEventsTrail.resize(0); |
| 5719 | UpdateInputEvents(g.IO.ConfigInputTrickleEventQueue); |
| 5720 | |
| 5721 | // Update viewports (after processing input queue, so io.MouseHoveredViewport is set) |
| 5722 | UpdateViewportsNewFrame(); |
| 5723 | |
| 5724 | // Update texture list (collect destroyed textures, etc.) |
| 5725 | UpdateTexturesNewFrame(); |
| 5726 | |
| 5727 | // Setup current font and draw list shared data |
| 5728 | SetupDrawListSharedData(); |
| 5729 | UpdateFontsNewFrame(); |
| 5730 | |
| 5731 | g.WithinFrameScope = true; |
| 5732 | |
| 5733 | // Mark rendering data as invalid to prevent user who may have a handle on it to use it. |
| 5734 | for (ImGuiViewportP* viewport : g.Viewports) |
| 5735 | { |
| 5736 | viewport->DrawData = NULL; |
| 5737 | viewport->DrawDataP.Valid = false; |
| 5738 | } |
| 5739 | |
| 5740 | // Drag and drop keep the source ID alive so even if the source disappear our state is consistent |
nothing calls this directly
no test coverage detected