Skip to content

fix: respect ImDrawCmd idx_offset in render_draw_list #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CrushedPixel
Copy link

@CrushedPixel CrushedPixel commented Jun 26, 2025

Checklist

  • cargo clippy reports no issues
  • cargo doc reports no issues
  • cargo deny issues have been fixed or added to deny.toml
  • human-readable change descriptions added to the changelog under the "Unreleased" heading.
    • If the change does not affect the user (or is a process change), preface the change with "Internal:"
    • Add credit to yourself for each change: Added new functionality @githubname.

Description

Previously, render_draw_list assumed all draw commands were contiguous in the index buffer and manually tracked a running index offset. This worked for older ImGui versions but breaks in version 1.86+, which relies on explicit idx_offset and vtx_offset values for correct layering, for example for modals and overlays.

@ocornut explains here why this breaks in 1.86+:
ocornut/imgui#4863 (comment)

This PR updates render_draw_list to use the provided offsets from ImDrawCmdParams, ensuring draw calls reference the correct index range regardless of command order.

This fixes a bug where fullscreen overlays (e.g. the ImGuiFileDialog modal overlay) were drawn in front of modal windows due to incorrect command ordering.

Old:
Screenshot 2025-06-26 at 22 55 40
New:
Screenshot 2025-06-26 at 22 50 52

In case you are interested in trying this, I have updated bindings to ImGuiFileDialog in my fork: https://github.com/CrushedPixel/imgui-filedialog-rs

Previously, render_draw_list assumed all draw commands were contiguous in the index buffer
and manually tracked a running index offset. This worked for older ImGui versions but breaks
in version 1.86+, which relies on explicit idx_offset and vtx_offset values for correct
layering, especially for modals and overlays.

This patch updates render_draw_list to use the provided offsets from ImDrawCmdParams,
ensuring draw calls reference the correct index range regardless of command order.

This fixes a bug where fullscreen overlays (e.g. the ImGuiFileDialog modal overlay) were drawn in front
of modal windows due to incorrect command ordering.
@ocornut
Copy link

ocornut commented Jun 26, 2025

Change looks correct to me, but Changelog says “internal” but it does affect the user (in a positive way), maybe should be marked as a bug fix instead.

@jbrd
Copy link
Contributor

jbrd commented Jul 22, 2025

Would it be possible to merge this please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants