MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / DebugNodeDrawList

Method DebugNodeDrawList

core/src/imgui/imgui.cpp:11295–11386  ·  view source on GitHub ↗

[DEBUG] Display contents of ImDrawList

Source from the content-addressed store, hash-verified

11293
11294// [DEBUG] Display contents of ImDrawList
11295void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label)
11296{
11297 ImGuiContext& g = *GImGui;
11298 ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
11299 int cmd_count = draw_list->CmdBuffer.Size;
11300 if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL)
11301 cmd_count--;
11302 bool node_open = TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, cmd_count);
11303 if (draw_list == GetWindowDrawList())
11304 {
11305 SameLine();
11306 TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
11307 if (node_open)
11308 TreePop();
11309 return;
11310 }
11311
11312 ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
11313 if (window && IsItemHovered())
11314 fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
11315 if (!node_open)
11316 return;
11317
11318 if (window && !window->WasActive)
11319 TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!");
11320
11321 for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++)
11322 {
11323 if (pcmd->UserCallback)
11324 {
11325 BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
11326 continue;
11327 }
11328
11329 char buf[300];
11330 ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
11331 pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId,
11332 pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
11333 bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf);
11334 if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list)
11335 DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes);
11336 if (!pcmd_node_open)
11337 continue;
11338
11339 // Calculate approximate coverage area (touched pixel count)
11340 // This will be in pixels squared as long there's no post-scaling happening to the renderer output.
11341 const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
11342 const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset;
11343 float total_area = 0.0f;
11344 for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; )
11345 {
11346 ImVec2 triangle[3];
11347 for (int n = 0; n < 3; n++, idx_n++)
11348 triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos;
11349 total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]);
11350 }
11351
11352 // Display vertex information summary. Hover to get all triangles drawn in wire-frame

Callers

nothing calls this directly

Calls 9

ImVec4Class · 0.85
GetForegroundDrawListFunction · 0.85
ImFormatStringFunction · 0.85
ImTriangleAreaFunction · 0.85
AddRectMethod · 0.80
AddPolylineMethod · 0.80
beginMethod · 0.45
BeginMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected