1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-12 02:00:58 +01:00

ImDrawList: Fix broken channel splitting (broken by d1e8b69) (#2591)

This commit is contained in:
omar 2019-05-30 18:47:46 +02:00
parent 546b728199
commit 42c98c5eea

View File

@ -568,7 +568,10 @@ void ImDrawList::ChannelsMerge()
if (CmdBuffer.Size && CmdBuffer.back().ElemCount == 0)
CmdBuffer.pop_back();
int new_cmd_buffer_count = 0, new_idx_buffer_count = 0;
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
int new_cmd_buffer_count = 0;
int new_idx_buffer_count = 0;
int idx_offset = CmdBuffer.back().IdxOffset + CmdBuffer.back().ElemCount;
for (int i = 1; i < _ChannelsCount; i++)
{
ImDrawChannel& ch = _Channels[i];
@ -576,10 +579,16 @@ void ImDrawList::ChannelsMerge()
ch.CmdBuffer.pop_back();
new_cmd_buffer_count += ch.CmdBuffer.Size;
new_idx_buffer_count += ch.IdxBuffer.Size;
for (int cmd_n = 0; cmd_n < ch.CmdBuffer.Size; cmd_n++)
{
ch.CmdBuffer.Data[cmd_n].IdxOffset = idx_offset;
idx_offset += ch.CmdBuffer.Data[cmd_n].ElemCount;
}
}
CmdBuffer.resize(CmdBuffer.Size + new_cmd_buffer_count);
IdxBuffer.resize(IdxBuffer.Size + new_idx_buffer_count);
// Flatten our N channels at the end of the first one.
ImDrawCmd* cmd_write = CmdBuffer.Data + CmdBuffer.Size - new_cmd_buffer_count;
_IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size - new_idx_buffer_count;
for (int i = 1; i < _ChannelsCount; i++)