Skip to content

Update to Dear ImGui v1.92.7 - #848

Draft
arnalon wants to merge 3 commits into
imgui-rs:mainfrom
arnalon:imgui-1.92.7
Draft

arnalon wants to merge 3 commits into
imgui-rs:mainfrom
arnalon:imgui-1.92.7

Conversation

@arnalon

@arnalon arnalon commented Oct 1, 2026

Copy link
Copy Markdown

Follows on from #834 and from @jestarray's request that I open a PR.

Draft, deliberately. imgui-sys builds; the imgui crate does not compile yet. Ten errors remain, in two groups, both of which I think are your calls rather than mine (details at the bottom). Everything mechanical is done, including the parts that are tedious to reproduce locally.

This is my arcdps-1.92.7 branch with the fork-specific bits taken back out: IMGUI_USE_WCHAR32 and IMGUI_DISABLE_OBSOLETE_FUNCTIONS are restored to upstream's settings, so ImWchar is 32-bit again and the obsolete API surface stays off. It is rebased on current main rather than carrying arcdps's imconfig changes.

What's here

1. Vendor Dear ImGui v1.92.7 — all four trees (imgui-master, imgui-docking, and both freetype variants), not just master, via third-party/update-imgui.sh with the pinned tags bumped.

2. Regenerate cimgui + Rust bindings — generated with cimgui 0e533fd, the revision contemporary with 1.92.7. Note that cimgui master has since had a cpp2ffi refactor, so a newer cimgui will not reproduce this output.

Three xtask/src/bindgen.rs fixes were needed:

  • --size_t-is-usize was removed from bindgen; it is the default now.
  • --ctypes-prefix has to be core::ffi rather than the cty shim. The committed bindings already used core::ffi, so this flag was already stale on main.
  • This one is a trap worth knowing about. cimgui 1.92 no longer resolves IMGUI_USE_WCHAR32 and IMGUI_ENABLE_FREETYPE while generating — it leaves them as #ifdefs in cimgui.h. bindgen therefore has to be passed the same defines imgui-sys/build.rs compiles the C++ with. Without -DIMGUI_USE_WCHAR32 the header's #else branch wins and ImWchar binds as 16-bit against a 32-bit C++ build, silently. I've verified all eight generated files now resolve ImWchar = ImWchar32, and that freetype/docking symbols appear only in their own variants.

3. Port the high-level crate — the ImVec2-by-value change, ImTextureRef/TexRef, igImageWithBg, sized PushFont, AddCallback userdata size, the new enum slots, and FontAtlas rebuilt as a #[repr(transparent)] wrapper over sys::ImFontAtlas.

Plus the renames that IMGUI_DISABLE_OBSOLETE_FUNCTIONS makes load-bearing: ImGuiCol_NavHighlight → NavCursor, NavLeftJumpsBackHere → NavLeftJumpsToParent, FittingPolicyResizeDown → FittingPolicyShrink, and the ConfigFlags nav entries that became io booleans in 1.91.4. ImGuiColorEditFlags_AlphaPreview needed more than a rename: 1.91.8 inverted the default, so a transparent preview is now standard and ColorPreview::Opaque maps onto the new AlphaOpaque flag.

What I've left for you

The font atlas (3 errors). With obsolete functions off, ImFontAtlas::{Build, GetTexDataAsAlpha8, GetTexDataAsRGBA32, IsBuilt} are all gone, and ImFontAtlasBuildMain is imgui_internal only — not exposed even by the docking variant's internal generation. So there is no supported way to build the atlas and read pixels before NewFrame, which is exactly what FontAtlas::build_rgba32_texture() and every renderer backend currently rely on.

The 1.92 answer is for backends to set ImGuiBackendFlags_RendererHasTextures and drain ImDrawData::Textures each frame. That is a breaking change for every backend, so it wants a deliberate decision — though it's worth noting backends already break here regardless, since ImDrawCmd::TextureId became TexRef.

Glyph ranges (7 errors). The seven non-default GetGlyphRanges* helpers are obsolete-only now; only GetGlyphRangesDefault survives. Either the tables get vendored into Rust so FontGlyphRanges::japanese() etc. keep working, or the helpers go and users move to ImFontGlyphRangesBuilder / dynamic loading. 1.92 considers explicit ranges unnecessary once a backend supports RendererHasTextures, which argues for removal, but it is a visible API break either way.

Two things I noticed but did not touch:

  • Io is a hand-maintained #[repr(C)] mirror of ImGuiIO, and 1.92 reordered that struct and dropped FontGlobalScale. It is wrong now. test_io_memory_layout catches it, so it fails loudly rather than corrupting silently, but it needs the same treatment FontAtlas got in this PR.
  • Font is a mirror of ImFont with the same problem, and 1.92 reworked ImFont substantially. push_font reads LegacySize through sys::ImFont rather than through Font for this reason.

This is the same hazard that motivated replacing the FontAtlas mirror: a drifting #[repr(C)] mirror doesn't fail to compile, it corrupts memory.

Expected CI state

CI on this PR will be red, and that is expected rather than a surprise:

  • ci.yml triggers on pull_request with no draft filter, so the test job runs on all three OSes and fails — the imgui crate does not compile, per the two groups above.
  • The rustfmt and clippy jobs are gated on github.ref == 'refs/heads/main', so they do not run on this PR. There is no lint or formatting signal here, only the build.
  • MSRV is pinned at Rust 1.82. I built locally with 1.97 and have not checked the regenerated bindings or the port against 1.82, so there may be further failures beyond the ten known errors.

All this has been done by AI, so do check it. I will push it as a Draft so you have the important changes, but do not intend to revisit this, so if you want them, please finish it yourself.

Updates all four vendored trees (master, docking, and the freetype variants)
from v1.91.3 to v1.92.7 via third-party/update-imgui.sh, and bumps the tags
the script pins.
Generated with cimgui 0e533fd, the revision contemporary with imgui 1.92.7
(cimgui master has since had a cpp2ffi refactor).

xtask changes needed to drive bindgen 0.72 and the 1.92-era cimgui output:

- `--size_t-is-usize` was removed from bindgen; it is the default now.
- `--ctypes-prefix` has to be `core::ffi` rather than the `cty` shim, which
  is what the committed bindings already used.
- cimgui 1.92 leaves `IMGUI_USE_WCHAR32` and `IMGUI_ENABLE_FREETYPE` as
  `#ifdef`s in the generated header instead of resolving them at generation
  time, so bindgen has to be given the same defines imgui-sys compiles the
  C++ with. Without `-DIMGUI_USE_WCHAR32` the header's `#else` branch wins
  and `ImWchar` would silently bind as 16-bit.
Mechanical half of the 1.92 port. Does not compile yet: see the two groups
left in `FontAtlas` and `FontGlyphRanges` below.

- cimgui now returns ImVec2 by value instead of through an out-parameter.
- Textures are passed as ImTextureRef; TextureId gains as_tex_ref(), and
  ImDrawCmd::TextureId became TexRef (resolved via ImTextureRef_GetTexID).
- igImage lost its border colour (borders come from ImGuiCol_Border now), so
  the tinted path goes through igImageWithBg.
- PushFont requires a size; push_font() keeps the font's own LegacySize.
- ImDrawList_AddCallback takes a userdata size.
- New 1.92 enum slots: ImGuiKey_Oem102, MouseCursor Wait/Progress, and the
  StyleColor slots InputTextCursor/TreeLines/DragDropTargetBg/UnsavedMarker.
- FontAtlas is now a transparent wrapper over sys::ImFontAtlas rather than a
  hand-maintained field mirror: 1.92 reworked the atlas, and a drifting mirror
  corrupts memory instead of failing to compile. FontConfig follows the
  renames (GlyphExtraAdvanceX, FontLoaderFlags, 8-bit oversampling).

Renames and moves that IMGUI_DISABLE_OBSOLETE_FUNCTIONS makes load-bearing:

- ImGuiCol_NavHighlight -> ImGuiCol_NavCursor (StyleColor::NavCursor).
- ImGuiTreeNodeFlags_NavLeftJumpsBackHere -> NavLeftJumpsToParent, and the
  builder method follows it.
- ImGuiTabBarFlags_FittingPolicyResizeDown -> FittingPolicyShrink.
- ImGuiColorEditFlags_AlphaPreview was removed in 1.91.8: a transparent
  preview is the default now, and AlphaOpaque restores the old behaviour, so
  ColorPreview maps onto ALPHA_OPAQUE rather than ALPHA_PREVIEW. AlphaNoBg
  is exposed as well.
- ImGuiConfigFlags_NavEnableSetMousePos / _NavNoCaptureKeyboard moved out of
  ImGuiConfigFlags in 1.91.4 and are now io booleans.
- ImGui::SetWindowFontScale() is obsolete with no drop-in replacement, so
  Ui::set_window_font_scale is removed pending a maintainer decision.
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.

2 participants