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

Method PrimReserve

TheForceEngine/TFE_Ui/imGUI/imgui_draw.cpp:631–654  ·  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

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