Prepare the data for rendering so you can call GetDrawData() (As with anything within the ImGui:: namspace this doesn't touch your GPU or graphics API at all: it is the role of the ImGui_ImplXXXX_RenderDrawData() function provided by the renderer backend)
| 5060 | // (As with anything within the ImGui:: namspace this doesn't touch your GPU or graphics API at all: |
| 5061 | // it is the role of the ImGui_ImplXXXX_RenderDrawData() function provided by the renderer backend) |
| 5062 | void ImGui::Render() |
| 5063 | { |
| 5064 | ImGuiContext& g = *GImGui; |
| 5065 | IM_ASSERT(g.Initialized); |
| 5066 | |
| 5067 | if (g.FrameCountEnded != g.FrameCount) |
| 5068 | EndFrame(); |
| 5069 | if (g.FrameCountRendered == g.FrameCount) |
| 5070 | return; |
| 5071 | g.FrameCountRendered = g.FrameCount; |
| 5072 | |
| 5073 | g.IO.MetricsRenderWindows = 0; |
| 5074 | CallContextHooks(&g, ImGuiContextHookType_RenderPre); |
| 5075 | |
| 5076 | // Draw modal/window whitening backgrounds |
| 5077 | RenderDimmedBackgrounds(); |
| 5078 | |
| 5079 | // Add background ImDrawList (for each active viewport) |
| 5080 | for (ImGuiViewportP* viewport : g.Viewports) |
| 5081 | { |
| 5082 | InitViewportDrawData(viewport); |
| 5083 | if (viewport->BgFgDrawLists[0] != NULL) |
| 5084 | AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport)); |
| 5085 | } |
| 5086 | |
| 5087 | // Add ImDrawList to render |
| 5088 | ImGuiWindow* windows_to_render_top_most[2]; |
| 5089 | windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL; |
| 5090 | windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL); |
| 5091 | for (ImGuiWindow* window : g.Windows) |
| 5092 | { |
| 5093 | IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'" |
| 5094 | if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1]) |
| 5095 | AddRootWindowToDrawData(window); |
| 5096 | } |
| 5097 | for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++) |
| 5098 | if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window |
| 5099 | AddRootWindowToDrawData(windows_to_render_top_most[n]); |
| 5100 | |
| 5101 | // Draw software mouse cursor if requested by io.MouseDrawCursor flag |
| 5102 | if (g.IO.MouseDrawCursor && g.MouseCursor != ImGuiMouseCursor_None) |
| 5103 | RenderMouseCursor(g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48)); |
| 5104 | |
| 5105 | // Setup ImDrawData structures for end-user |
| 5106 | g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0; |
| 5107 | for (ImGuiViewportP* viewport : g.Viewports) |
| 5108 | { |
| 5109 | FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder); |
| 5110 | |
| 5111 | // Add foreground ImDrawList (for each active viewport) |
| 5112 | if (viewport->BgFgDrawLists[1] != NULL) |
| 5113 | AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport)); |
| 5114 | |
| 5115 | // We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch). |
| 5116 | ImDrawData* draw_data = &viewport->DrawDataP; |
| 5117 | IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount); |
| 5118 | for (ImDrawList* draw_list : draw_data->CmdLists) |
| 5119 | draw_list->_PopUnusedDrawCmd(); |
nothing calls this directly
no test coverage detected