MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / AddDrawListToDrawData

Function AddDrawListToDrawData

lib/imgui/imgui.cpp:3964–4004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3962}
3963
3964static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
3965{
3966 if (draw_list->CmdBuffer.empty())
3967 return;
3968
3969 // Remove trailing command if unused
3970 ImDrawCmd& last_cmd = draw_list->CmdBuffer.back();
3971 if (last_cmd.ElemCount == 0 && last_cmd.UserCallback == NULL)
3972 {
3973 draw_list->CmdBuffer.pop_back();
3974 if (draw_list->CmdBuffer.empty())
3975 return;
3976 }
3977
3978 // Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
3979 // May trigger for you if you are using PrimXXX functions incorrectly.
3980 IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
3981 IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
3982 if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
3983 IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
3984
3985 // Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
3986 // If this assert triggers because you are drawing lots of stuff manually:
3987 // - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
3988 // Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics window to inspect draw list contents.
3989 // - If you want large meshes with more than 64K vertices, you can either:
3990 // (A) Handle the ImDrawCmd::VtxOffset value in your renderer back-end, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
3991 // Most example back-ends already support this from 1.71. Pre-1.71 back-ends won't.
3992 // Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
3993 // (B) Or handle 32-bit indices in your renderer back-end, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
3994 // Most example back-ends already support this. For example, the OpenGL example code detect index size at compile-time:
3995 // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
3996 // Your own engine or render API may use different parameters or function calls to specify index sizes.
3997 // 2 and 4 bytes indices are generally supported by most graphics API.
3998 // - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
3999 // the 64K limit to split your draw commands in multiple draw lists.
4000 if (sizeof(ImDrawIdx) == 2)
4001 IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
4002
4003 out_list->push_back(draw_list);
4004}
4005
4006static void AddWindowToDrawData(ImVector<ImDrawList*>* out_render_list, ImGuiWindow* window)
4007{

Callers 2

AddWindowToDrawDataFunction · 0.85
RenderMethod · 0.85

Calls 4

pop_backMethod · 0.80
emptyMethod · 0.45
backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected