Skip to content

Commit

Permalink
Canvas: Remember index of first command buffer to not miss updating a…
Browse files Browse the repository at this point in the history
…ny used (#260)
  • Loading branch information
thedmd committed Oct 21, 2023
1 parent 084736a commit 383099c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
v0.9.4 (WIP):

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

v0.9.3 (2023-10-14):

Expand Down
6 changes: 4 additions & 2 deletions imgui_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ void ImGuiEx::Canvas::EnterLocalSpace()
if ((!m_DrawList->CmdBuffer.empty() && m_DrawList->CmdBuffer.back().ElemCount > 0) || m_DrawList->_Splitter._Count > 1)
m_DrawList->AddCallback(ImDrawCallback_ImCanvas, nullptr);

m_DrawListFirstCommandIndex = ImMax(m_DrawList->CmdBuffer.Size - 1, 0);

# if defined(IMGUI_HAS_VIEWPORT)
auto window = ImGui::GetCurrentWindow();
window->Pos = ImVec2(0.0f, 0.0f);
Expand Down Expand Up @@ -523,7 +525,7 @@ void ImGuiEx::Canvas::LeaveLocalSpace()
}

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

// Move clip rectangles to screen space.
for (int i = m_DrawListCommadBufferSize; i < m_DrawList->CmdBuffer.size(); ++i)
for (int i = m_DrawListFirstCommandIndex; i < m_DrawList->CmdBuffer.size(); ++i)
{
auto& command = m_DrawList->CmdBuffer[i];
command.ClipRect.x = command.ClipRect.x + m_ViewTransformPosition.x;
Expand Down
1 change: 1 addition & 0 deletions imgui_canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ struct Canvas
Range* m_CurrentRange = nullptr;
# endif

int m_DrawListFirstCommandIndex = 0;
int m_DrawListCommadBufferSize = 0;
int m_DrawListStartVertexIndex = 0;

Expand Down

0 comments on commit 383099c

Please sign in to comment.