MCPcopy Create free account
hub / github.com/RenderKit/embree / PrimReserve

Method PrimReserve

tutorials/common/imgui/imgui_draw.cpp:616–639  ·  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

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