diff --git a/addons/imgui-godot/ImGuiGD.cs b/addons/imgui-godot/ImGuiGD.cs
index 01d6eb4..af16a14 100644
--- a/addons/imgui-godot/ImGuiGD.cs
+++ b/addons/imgui-godot/ImGuiGD.cs
@@ -302,7 +302,6 @@ private static void RenderDrawData(ImDrawDataPtr drawData, RID parent)
         for (int n = 0; n < drawData.CmdListsCount; n++)
         {
             ImDrawListPtr cmdList = drawData.CmdListsRange[n];
-            int idxOffset = 0;
 
             int nVert = cmdList.VtxBuffer.Size;
 
@@ -325,6 +324,7 @@ private static void RenderDrawData(ImDrawDataPtr drawData, RID parent)
                 ImDrawCmdPtr drawCmd = cmdList.CmdBuffer[cmdi];
 
                 int[] indices = new int[drawCmd.ElemCount];
+                int idxOffset = (int)drawCmd.IdxOffset;
                 for (int i = idxOffset, j = 0; i < idxOffset + drawCmd.ElemCount; i++, j++)
                 {
                     indices[j] = cmdList.IdxBuffer[i];