Skip to content

Commit 383099c

Browse files
committed
Canvas: Remember index of first command buffer to not miss updating any used (#260)
1 parent 084736a commit 383099c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

docs/CHANGELOG.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
v0.9.4 (WIP):
22

3-
nothing yet
3+
BUGFIX: Canvas: Remember index of first command buffer to not miss updating any used (#260)
44

55
v0.9.3 (2023-10-14):
66

imgui_canvas.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ void ImGuiEx::Canvas::EnterLocalSpace()
445445
if ((!m_DrawList->CmdBuffer.empty() && m_DrawList->CmdBuffer.back().ElemCount > 0) || m_DrawList->_Splitter._Count > 1)
446446
m_DrawList->AddCallback(ImDrawCallback_ImCanvas, nullptr);
447447

448+
m_DrawListFirstCommandIndex = ImMax(m_DrawList->CmdBuffer.Size - 1, 0);
449+
448450
# if defined(IMGUI_HAS_VIEWPORT)
449451
auto window = ImGui::GetCurrentWindow();
450452
window->Pos = ImVec2(0.0f, 0.0f);
@@ -523,7 +525,7 @@ void ImGuiEx::Canvas::LeaveLocalSpace()
523525
}
524526

525527
// Move clip rectangles to screen space.
526-
for (int i = m_DrawListCommadBufferSize; i < m_DrawList->CmdBuffer.size(); ++i)
528+
for (int i = m_DrawListFirstCommandIndex; i < m_DrawList->CmdBuffer.size(); ++i)
527529
{
528530
auto& command = m_DrawList->CmdBuffer[i];
529531
command.ClipRect.x = command.ClipRect.x * m_View.Scale + m_ViewTransformPosition.x;
@@ -542,7 +544,7 @@ void ImGuiEx::Canvas::LeaveLocalSpace()
542544
}
543545

544546
// Move clip rectangles to screen space.
545-
for (int i = m_DrawListCommadBufferSize; i < m_DrawList->CmdBuffer.size(); ++i)
547+
for (int i = m_DrawListFirstCommandIndex; i < m_DrawList->CmdBuffer.size(); ++i)
546548
{
547549
auto& command = m_DrawList->CmdBuffer[i];
548550
command.ClipRect.x = command.ClipRect.x + m_ViewTransformPosition.x;

imgui_canvas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ struct Canvas
236236
Range* m_CurrentRange = nullptr;
237237
# endif
238238

239+
int m_DrawListFirstCommandIndex = 0;
239240
int m_DrawListCommadBufferSize = 0;
240241
int m_DrawListStartVertexIndex = 0;
241242

0 commit comments

Comments
 (0)