| 3894 | } |
| 3895 | |
| 3896 | void ImGui::NewFrame() |
| 3897 | { |
| 3898 | IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); |
| 3899 | ImGuiContext& g = *GImGui; |
| 3900 | |
| 3901 | // Remove pending delete hooks before frame start. |
| 3902 | // This deferred removal avoid issues of removal while iterating the hook vector |
| 3903 | for (int n = g.Hooks.Size - 1; n >= 0; n--) |
| 3904 | if (g.Hooks[n].Type == ImGuiContextHookType_PendingRemoval_) |
| 3905 | g.Hooks.erase(&g.Hooks[n]); |
| 3906 | |
| 3907 | CallContextHooks(&g, ImGuiContextHookType_NewFramePre); |
| 3908 | |
| 3909 | // Check and assert for various common IO and Configuration mistakes |
| 3910 | ErrorCheckNewFrameSanityChecks(); |
| 3911 | |
| 3912 | // Load settings on first frame, save settings when modified (after a delay) |
| 3913 | UpdateSettings(); |
| 3914 | |
| 3915 | g.Time += g.IO.DeltaTime; |
| 3916 | g.WithinFrameScope = true; |
| 3917 | g.FrameCount += 1; |
| 3918 | g.TooltipOverrideCount = 0; |
| 3919 | g.WindowsActiveCount = 0; |
| 3920 | g.MenusIdSubmittedThisFrame.resize(0); |
| 3921 | |
| 3922 | // Calculate frame-rate for the user, as a purely luxurious feature |
| 3923 | g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; |
| 3924 | g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; |
| 3925 | g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); |
| 3926 | g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame)); |
| 3927 | g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX; |
| 3928 | |
| 3929 | UpdateViewportsNewFrame(); |
| 3930 | |
| 3931 | // Setup current font and draw list shared data |
| 3932 | g.IO.Fonts->Locked = true; |
| 3933 | SetCurrentFont(GetDefaultFont()); |
| 3934 | IM_ASSERT(g.Font->IsLoaded()); |
| 3935 | ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); |
| 3936 | for (int n = 0; n < g.Viewports.Size; n++) |
| 3937 | virtual_space.Add(g.Viewports[n]->GetMainRect()); |
| 3938 | g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4(); |
| 3939 | g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol; |
| 3940 | g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError); |
| 3941 | g.DrawListSharedData.InitialFlags = ImDrawListFlags_None; |
| 3942 | if (g.Style.AntiAliasedLines) |
| 3943 | g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines; |
| 3944 | if (g.Style.AntiAliasedLinesUseTex && !(g.Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines)) |
| 3945 | g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLinesUseTex; |
| 3946 | if (g.Style.AntiAliasedFill) |
| 3947 | g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill; |
| 3948 | if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) |
| 3949 | g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset; |
| 3950 | |
| 3951 | // Mark rendering data as invalid to prevent user who may have a handle on it to use it. |
| 3952 | for (int n = 0; n < g.Viewports.Size; n++) |
| 3953 | { |
nothing calls this directly
no test coverage detected