diff --git a/imgui.h b/imgui.h index 03e94df7..b967d5be 100644 --- a/imgui.h +++ b/imgui.h @@ -1840,7 +1840,7 @@ struct ImDrawListSplitter inline void Clear() { _Current = 0; _Count = 1; } // Do not clear Channels[] so our allocations are reused next frame IMGUI_API void ClearFreeMemory(); IMGUI_API void Split(ImDrawList* draw_list, int count); - IMGUI_API void Merge(ImDrawList* draw_lists); + IMGUI_API void Merge(ImDrawList* draw_list); IMGUI_API void SetCurrentChannel(ImDrawList* draw_list, int channel_idx); }; diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 25671768..cba3e76a 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1267,12 +1267,13 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list) for (int i = 1; i < _Count; i++) { ImDrawChannel& ch = _Channels[i]; - if (ch.CmdBuffer.Size && ch.CmdBuffer.back().ElemCount == 0) + if (ch.CmdBuffer.Size > 0 && ch.CmdBuffer.back().ElemCount == 0) ch.CmdBuffer.pop_back(); - else if (ch.CmdBuffer.Size > 0 && last_cmd != NULL && CanMergeDrawCommands(last_cmd, &ch.CmdBuffer[0])) + if (ch.CmdBuffer.Size > 0 && last_cmd != NULL && CanMergeDrawCommands(last_cmd, &ch.CmdBuffer[0])) { // Merge previous channel last draw command with current channel first draw command if matching. last_cmd->ElemCount += ch.CmdBuffer[0].ElemCount; + idx_offset += ch.CmdBuffer[0].ElemCount; ch.CmdBuffer.erase(ch.CmdBuffer.Data); } if (ch.CmdBuffer.Size > 0)