MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / Render

Method Render

TheForceEngine/TFE_Ui/imGUI/imgui.cpp:5239–5303  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

5237// (As with anything within the ImGui:: namspace this doesn't touch your GPU or graphics API at all:
5238// it is the role of the ImGui_ImplXXXX_RenderDrawData() function provided by the renderer backend)
5239void ImGui::Render()
5240{
5241 ImGuiContext& g = *GImGui;
5242 IM_ASSERT(g.Initialized);
5243
5244 if (g.FrameCountEnded != g.FrameCount)
5245 EndFrame();
5246 if (g.FrameCountRendered == g.FrameCount)
5247 return;
5248 g.FrameCountRendered = g.FrameCount;
5249
5250 g.IO.MetricsRenderWindows = 0;
5251 CallContextHooks(&g, ImGuiContextHookType_RenderPre);
5252
5253 // Draw modal/window whitening backgrounds
5254 RenderDimmedBackgrounds();
5255
5256 // Add background ImDrawList (for each active viewport)
5257 for (ImGuiViewportP* viewport : g.Viewports)
5258 {
5259 InitViewportDrawData(viewport);
5260 if (viewport->BgFgDrawLists[0] != NULL)
5261 AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
5262 }
5263
5264 // Add ImDrawList to render
5265 ImGuiWindow* windows_to_render_top_most[2];
5266 windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
5267 windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL);
5268 for (ImGuiWindow* window : g.Windows)
5269 {
5270 IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'"
5271 if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1])
5272 AddRootWindowToDrawData(window);
5273 }
5274 for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++)
5275 if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window
5276 AddRootWindowToDrawData(windows_to_render_top_most[n]);
5277
5278 // Draw software mouse cursor if requested by io.MouseDrawCursor flag
5279 if (g.IO.MouseDrawCursor && g.MouseCursor != ImGuiMouseCursor_None)
5280 RenderMouseCursor(g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
5281
5282 // Setup ImDrawData structures for end-user
5283 g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
5284 for (ImGuiViewportP* viewport : g.Viewports)
5285 {
5286 FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
5287
5288 // Add foreground ImDrawList (for each active viewport)
5289 if (viewport->BgFgDrawLists[1] != NULL)
5290 AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
5291
5292 // We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
5293 ImDrawData* draw_data = &viewport->DrawDataP;
5294 IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
5295 for (ImDrawList* draw_list : draw_data->CmdLists)
5296 draw_list->_PopUnusedDrawCmd();

Callers

nothing calls this directly

Calls 6

InitViewportDrawDataFunction · 0.85
IsWindowActiveAndVisibleFunction · 0.85
AddRootWindowToDrawDataFunction · 0.85
GetForegroundDrawListFunction · 0.85
_PopUnusedDrawCmdMethod · 0.80

Tested by

no test coverage detected