1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

ImDrawListSplitter: Fix idx offset when merging (cef88f6) (#2591)

This commit is contained in:
omar 2019-06-10 15:02:16 +02:00
parent 0770449630
commit d8435c7710
2 changed files with 4 additions and 3 deletions

View File

@ -1840,7 +1840,7 @@ struct ImDrawListSplitter
inline void Clear() { _Current = 0; _Count = 1; } // Do not clear Channels[] so our allocations are reused next frame 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 ClearFreeMemory();
IMGUI_API void Split(ImDrawList* draw_list, int count); 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); IMGUI_API void SetCurrentChannel(ImDrawList* draw_list, int channel_idx);
}; };

View File

@ -1267,12 +1267,13 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
for (int i = 1; i < _Count; i++) for (int i = 1; i < _Count; i++)
{ {
ImDrawChannel& ch = _Channels[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(); 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. // Merge previous channel last draw command with current channel first draw command if matching.
last_cmd->ElemCount += ch.CmdBuffer[0].ElemCount; last_cmd->ElemCount += ch.CmdBuffer[0].ElemCount;
idx_offset += ch.CmdBuffer[0].ElemCount;
ch.CmdBuffer.erase(ch.CmdBuffer.Data); ch.CmdBuffer.erase(ch.CmdBuffer.Data);
} }
if (ch.CmdBuffer.Size > 0) if (ch.CmdBuffer.Size > 0)