MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / PrimReserve

Method PrimReserve

extern/imgui/imgui_draw.cpp:625–648  ·  view source on GitHub ↗

Reserve space for a number of vertices and indices. You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or submit the intermediate results. PrimUnreserve() can be used to release unused allocations.

Source from the content-addressed store, hash-verified

623// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or
624// submit the intermediate results. PrimUnreserve() can be used to release unused allocations.
625void ImDrawList::PrimReserve(int idx_count, int vtx_count)
626{
627 // Large mesh support (when enabled)
628 IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
629 if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
630 {
631 // FIXME: In theory we should be testing that vtx_count <64k here.
632 // In practice, RenderText() relies on reserving ahead for a worst case scenario so it is currently useful for us
633 // to not make that check until we rework the text functions to handle clipping and large horizontal lines better.
634 _CmdHeader.VtxOffset = VtxBuffer.Size;
635 _OnChangedVtxOffset();
636 }
637
638 ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
639 draw_cmd->ElemCount += idx_count;
640
641 int vtx_buffer_old_size = VtxBuffer.Size;
642 VtxBuffer.resize(vtx_buffer_old_size + vtx_count);
643 _VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size;
644
645 int idx_buffer_old_size = IdxBuffer.Size;
646 IdxBuffer.resize(idx_buffer_old_size + idx_count);
647 _IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
648}
649
650// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
651void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)

Callers 3

RenderCharMethod · 0.80
RenderTextMethod · 0.80
ColorPicker4Method · 0.80

Calls 1

resizeMethod · 0.45

Tested by

no test coverage detected