mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	ImDrawList: Fixed VtxOffset change leading to unnecessary leading empty ImDrawCmd in certain cases.
This commit is contained in:
		| @@ -514,6 +514,21 @@ void ImDrawList::_OnChangedTextureID() | ||||
|     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) | ||||
| 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)) | ||||
|     { | ||||
|         _CmdHeader.VtxOffset = VtxBuffer.Size; | ||||
|         _VtxCurrentIdx = 0; | ||||
|         AddDrawCmd(); | ||||
|         _OnChangedVtxOffset(); | ||||
|     } | ||||
|  | ||||
|     ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user