mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
ImDrawList: Fixed VtxOffset change leading to unnecessary leading empty ImDrawCmd in certain cases.
This commit is contained in:
parent
16da8e6da6
commit
64d8d302fb
1
imgui.h
1
imgui.h
@ -2075,6 +2075,7 @@ struct ImDrawList
|
|||||||
IMGUI_API void _PopUnusedDrawCmd();
|
IMGUI_API void _PopUnusedDrawCmd();
|
||||||
IMGUI_API void _OnChangedClipRect();
|
IMGUI_API void _OnChangedClipRect();
|
||||||
IMGUI_API void _OnChangedTextureID();
|
IMGUI_API void _OnChangedTextureID();
|
||||||
|
IMGUI_API void _OnChangedVtxOffset();
|
||||||
};
|
};
|
||||||
|
|
||||||
// All draw data to render a Dear ImGui frame
|
// All draw data to render a Dear ImGui frame
|
||||||
|
@ -514,6 +514,21 @@ void ImDrawList::_OnChangedTextureID()
|
|||||||
curr_cmd->TextureId = _CmdHeader.TextureId;
|
curr_cmd->TextureId = _CmdHeader.TextureId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImDrawList::_OnChangedVtxOffset()
|
||||||
|
{
|
||||||
|
// We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this.
|
||||||
|
_VtxCurrentIdx = 0;
|
||||||
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
|
IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset);
|
||||||
|
if (curr_cmd->ElemCount != 0)
|
||||||
|
{
|
||||||
|
AddDrawCmd();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
||||||
|
curr_cmd->VtxOffset = _CmdHeader.VtxOffset;
|
||||||
|
}
|
||||||
|
|
||||||
// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
||||||
void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect)
|
void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect)
|
||||||
{
|
{
|
||||||
@ -570,8 +585,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
|||||||
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
||||||
{
|
{
|
||||||
_CmdHeader.VtxOffset = VtxBuffer.Size;
|
_CmdHeader.VtxOffset = VtxBuffer.Size;
|
||||||
_VtxCurrentIdx = 0;
|
_OnChangedVtxOffset();
|
||||||
AddDrawCmd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
|
Loading…
Reference in New Issue
Block a user