MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / Render

Method Render

imgui_tiny_app/imgui/imgui.cpp:6342–6412  ·  view source on GitHub ↗

Prepare the data for rendering so you can call GetDrawData() (As with anything within the ImGui:: namespace 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

6340// (As with anything within the ImGui:: namespace this doesn't touch your GPU or graphics API at all:
6341// it is the role of the ImGui_ImplXXXX_RenderDrawData() function provided by the renderer backend)
6342void ImGui::Render()
6343{
6344 ImGuiContext& g = *GImGui;
6345 IM_ASSERT(g.Initialized);
6346
6347 if (g.FrameCountEnded != g.FrameCount)
6348 EndFrame();
6349 if (g.FrameCountRendered == g.FrameCount)
6350 return;
6351 g.FrameCountRendered = g.FrameCount;
6352
6353 g.IO.MetricsRenderWindows = 0;
6354 CallContextHooks(&g, ImGuiContextHookType_RenderPre);
6355
6356 // Add background ImDrawList (for each active viewport)
6357 for (ImGuiViewportP* viewport : g.Viewports)
6358 {
6359 InitViewportDrawData(viewport);
6360 if (viewport->BgFgDrawLists[0] != NULL && viewport->BgFgDrawListsLastTimeActive[0] == (float)g.Time)
6361 AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
6362 }
6363
6364 // Draw modal/window whitening backgrounds
6365 RenderDimmedBackgrounds();
6366
6367 // Add ImDrawList to render
6368 ImGuiWindow* windows_to_render_top_most[2];
6369 windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindowDockTree : NULL;
6370 windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL);
6371 for (ImGuiWindow* window : g.Windows)
6372 {
6373 IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'"
6374 if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1])
6375 AddRootWindowToDrawData(window);
6376 }
6377 for (int n = 0; n < IM_COUNTOF(windows_to_render_top_most); n++)
6378 if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window
6379 AddRootWindowToDrawData(windows_to_render_top_most[n]);
6380
6381 // Draw software mouse cursor if requested by io.MouseDrawCursor flag
6382 if (g.IO.MouseDrawCursor && g.MouseCursor != ImGuiMouseCursor_None)
6383 RenderMouseCursor(g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
6384
6385 // Setup ImDrawData structures for end-user
6386 g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
6387 for (ImGuiViewportP* viewport : g.Viewports)
6388 {
6389 FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
6390
6391 // Add foreground ImDrawList (for each active viewport)
6392 if (viewport->BgFgDrawLists[1] != NULL && viewport->BgFgDrawListsLastTimeActive[1] == (float)g.Time)
6393 AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
6394
6395 // We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
6396 ImDrawData* draw_data = &viewport->DrawDataP;
6397 IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
6398 for (ImDrawList* draw_list : draw_data->CmdLists)
6399 draw_list->_PopUnusedDrawCmd();

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected