diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 9502bc48b74ce..3e32cf5cf7e4a 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -731,22 +731,27 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c #define IM_POLYLINE_IDX_16_BIT 0 #else #define IM_POLYLINE_IDX_16_BIT 1 -# endif - -// Macros that declare, load and save write pointers as local variables -#define IM_POLYLINE_PRIM_MAKE_LOCAL() ImDrawVert* vtx_write = this->_VtxWritePtr; ImDrawIdx* idx_write = this->_IdxWritePtr; unsigned int idx_base = this->_VtxCurrentIdx -#define IM_POLYLINE_PRIM_LOAD_LOCAL() vtx_write = this->_VtxWritePtr; idx_write = this->_IdxWritePtr; idx_base = this->_VtxCurrentIdx -#define IM_POLYLINE_PRIM_SAVE_LOCAL() this->_VtxWritePtr = vtx_write; this->_IdxWritePtr = idx_write; this->_VtxCurrentIdx = idx_base +#endif // Macros that commit, split and handle vertex offset overflow -#define IM_POLYLINE_PRIM_RESERVE(IDX_COUNT, VTX_COUNT) this->PrimReserve((IDX_COUNT) + IM_POLYLINE_PRIM_EXTRA_IDX_COUNT, VTX_COUNT); IM_POLYLINE_PRIM_MAKE_LOCAL() +#define IM_POLYLINE_PRIM_RESERVE(IDX_COUNT, VTX_COUNT) \ + this->PrimReserve((IDX_COUNT) + IM_POLYLINE_PRIM_EXTRA_IDX_COUNT, VTX_COUNT); \ + ImDrawVert* vtx_write = this->_VtxWritePtr; \ + ImDrawIdx* idx_write = this->_IdxWritePtr; \ + unsigned int idx_base = this->_VtxCurrentIdx; + #define IM_POLYLINE_PRIM_COMMIT() \ - IM_POLYLINE_PRIM_SAVE_LOCAL(); \ + this->_VtxWritePtr = vtx_write; this->_IdxWritePtr = idx_write; this->_VtxCurrentIdx = idx_base; \ const int unused_vtx_count = (int)((this->VtxBuffer.Data + this->VtxBuffer.Size) - this->_VtxWritePtr); \ const int unused_idx_count = (int)((this->IdxBuffer.Data + this->IdxBuffer.Size) - this->_IdxWritePtr); \ this->PrimUnreserve(unused_idx_count, unused_vtx_count) -#define IM_POLYLINE_PRIM_SPLT() IM_POLYLINE_PRIM_COMMIT(); this->PrimReserve(unused_idx_count, unused_vtx_count); IM_POLYLINE_PRIM_LOAD_LOCAL() +#define IM_POLYLINE_PRIM_SPLT() \ + IM_POLYLINE_PRIM_COMMIT(); \ + this->PrimReserve(unused_idx_count, unused_vtx_count); \ + vtx_write = this->_VtxWritePtr; \ + idx_write = this->_IdxWritePtr; \ + idx_base = this->_VtxCurrentIdx; #define IM_POLYLINE_VTX_COMMIT(N) \ { \