MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / PrimReserve

Method PrimReserve

ImGUI GLFW Tutorial/imgui/imgui_draw.cpp:614–637  ·  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

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

Callers 3

RenderCharMethod · 0.45
RenderTextMethod · 0.45
ColorPicker4Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected