moderngl-window icon indicating copy to clipboard operation
moderngl-window copied to clipboard

Many breaking changes in `imgui-bundle` version 1.92.0

Open Tremeschin opened this issue 8 months ago • 4 comments

Hi, Imgui got a huge release past few days with many fonts related code changes, breaking ModernGL's Window integration in potentially many ways (the dependency is unbounded, semver allows the new one), yet seems to have simplified font management scaling quite a bit:

  • pthom/imgui-bundle release mainly removed font_atlas_get_tex_data_as_rgba32 and related functions.
  • ocornut/imgui lists all the many breaking changes in the C part, which imgui-bundle tries to mirror.

I tried bypassing these fonts functions but a fix goes wayy deeper (Linux) for moderngl-window==3.1.1:

  File "/home/tremeschin/Code/.venv/lib/python3.13/site-packages/moderngl_window/integrations/imgui_bundle.py", line 167, in refresh_font_texture
    font_matrix = self.io.fonts.get_tex_data_as_rgba32()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'imgui_bundle._imgui_bundle.imgui.ImFontAtlas' object has no attribute 'get_tex_data_as_rgba32'

The easiest solution is to limit or downgrade to imgui-bundle<=1.6.3 in our projects, but most use >= or ~= pins which makes it quite worrisome as the new "bad" version is semver-compatible with everyone's current specifications.

  • Workaround: Downgrade to python3 -m pip install imgui-bundle==1.6.3 --force-reinstall
  • Or better yet, uv add imgui-bundle==1.6.3, poetry add imgui-bundle==1.6.3, etc.

Perhaps @highfestiva could help porting to the new version as he's done PRs #197 #196 😅, might need to make the new code specific to imgui-bundle>=1.92.0 though, or branching based on version (ugly), as back compat seems to be hard.

I'm writing this in a semi-hurry for a patch release of my projects for pinning <=1.6.3, might update with further info.

Tremeschin avatar Jun 29 '25 15:06 Tremeschin

Hi,

I am the author of ImGui Bundle. I'm sorry there was a breaking change, but the changes inside ImGui itself were big, and it was impossible to keep a complete backward compat.

Contact me if help is needed when updating to support dynamic fonts.

Here are some links to other backends which were updated after v1.92:

  • wgpu-py (WebGPU for Python): https://github.com/pygfx/wgpu-py/issues/723 (issue) and https://github.com/pygfx/wgpu-py/pull/725 (PR that solves the issue)

  • pygame: https://github.com/pthom/imgui_bundle/issues/369 (issue) and https://github.com/pthom/imgui_bundle/pull/372 (PR). Here, @d-orm mentions that he could get it to work on pyopengl/moderngl/zengl examples.

  • imgui-bundle adaptations in its internal opengl backend: https://github.com/pthom/imgui_bundle/blob/45da61745fc24c5ded350ea35e834dc9d73525fc/bindings/imgui_bundle/python_backends/opengl_base_backend.py#L45-L141

pthom avatar Jul 16 '25 10:07 pthom

Hi! My 2C here - I would propose two options for longer term moderngl-window solutions;

  • Update the moderngl-window rendering integration to use the new imgui_bundle interfaces that replaces font_atlas_get_tex_data_as_rgba32 (along with some other changes like texture ID access), which would look similar to the changes made in this pending PR (not my original rendering code, @szabolcsdombi 's wizardry on this, and is a similar implementation to what the moderngl-window integration is doing already):
- width, height, pixels = self.io.fonts.get_tex_data_as_rgba32()
+ tex_data = self.io.fonts.tex_data
+ width, height, pixels = tex_data.width, tex_data.height, tex_data.get_pixels_array()
  • Have moderngl-window integration implement the zengl-imgui renderer directly as ZenGL can seamlessly render along side moderngl in the same context, such as in this example (which currently uses original py-imgui, but once we merge above PR to switch zengl-imgui to imgui_bundle, it'll still work the same), and would just need to implement the mgl-window input handler extension as we've done with the Pygame one.

@einarf I'd be happy to contribute a PR to help with this

d-orm avatar Jul 16 '25 20:07 d-orm

Sorry, I'm busy to help out! I had a look recently, and it looks like a lot of work. I very much appreciate the lib, it's making my life so much easier, thanks!

I elected to freeze my own app on imgui-bundle<=1.6.3 so I don't have to set that time aside atm.

highfestiva avatar Oct 20 '25 11:10 highfestiva

See related proposed PR: https://github.com/moderngl/moderngl-window/pull/224

pthom avatar Nov 09 '25 23:11 pthom