Add ImTextureData-based texture management - #414
Conversation
Bind Dear ImGui 1.92's texture-management structs and enums so backends can drive ImGuiBackendFlags_RendererHasTextures: - ImTextureFormat / ImTextureStatus flag enums (AST-generated). - ImTextureRect wrapper (x/y/w/h of an update region). - ImTextureData wrapper exposing the struct fields (status, format, size, pixels, texID, update rects, ...) and binding through the C++ SetStatus/ SetTexID/Create/DestroyPixels methods. getPixels() returns a direct ByteBuffer over the native pixel buffer (no copy). These are the core-library/backend-facing types; end-user application code does not need them. Follow-up commits expose the per-frame texture lists and wire the LWJGL GL3 backend. Co-authored-by: Claude <noreply@anthropic.com>
Add the accessors a renderer backend needs to honor texture requests each frame: - ImDrawData.getTexturesSize()/getTextures(idx) over ImDrawData::Textures (may be NULL when texture updates are disabled). - ImGuiPlatformIO.getTexturesSize()/getTextures(idx) over the platform IO texture list, plus Renderer_TextureMaxWidth/Height getters and setters so the backend can advertise its maximum texture size. Co-authored-by: Claude <noreply@anthropic.com>
Wire ImGuiImplGl3 to Dear ImGui 1.92's texture-management system and enable ImGuiBackendFlags_RendererHasTextures end-to-end: - init(): advertise RendererHasTextures and publish the GL max texture size via ImGuiPlatformIO.Renderer_TextureMaxWidth/Height; shutdown() clears the flag. - renderDrawData(): before drawing, iterate ImDrawData's texture list and reconcile every non-OK ImTextureData with the GPU. - updateTexture()/destroyTexture(): create (glTexImage2D from the texture's pixel buffer), incrementally update (glTexSubImage2D over UpdateRect blocks using UNPACK_ROW_LENGTH) and destroy GL textures, reporting the new TexID/status back through the C++ SetTexID/SetStatus methods. - createDeviceObjects()/newFrame() no longer eagerly build the font texture; destroyDeviceObjects() frees every owned texture (RefCount == 1). The legacy createFontsTexture()/destroyFontsTexture() methods are kept and deprecated for source compatibility, but are no longer part of the frame loop. Co-authored-by: Claude <noreply@anthropic.com>
Add a "Texture Management" section to the example that reads the live ImTextureData list the GL3 backend now maintains (ImGuiBackendFlags_RendererHasTextures): it reports the backend flag state, lists each managed texture's id/size/format/status/texID, and renders the uploaded font-atlas texture inline via ImGui.image(). Co-authored-by: Claude <noreply@anthropic.com>
Rebuild bin/libimgui-java64.so (linux64) so the new ImTextureData / ImTextureRect / ImDrawData / ImGuiPlatformIO native methods resolve at runtime; without this the branch throws UnsatisfiedLinkError against the stale prebuilt library. NOTE: only the linux64 native is refreshed here — the macOS/Windows natives in bin/ still predate these JNI methods and will be regenerated by CI's post-merge native build. Co-authored-by: Claude <noreply@anthropic.com>
…s backend With the 1.92 texture-management backend the font atlas is baked lazily by the renderer. Calling build() explicitly sets PreloadedAllGlyphsRanges and trips the 'you don't need to call Build()' assertion in ImFontAtlasUpdateNewFrame, after which NewFrame proceeds with an inconsistent atlas and the render path crashes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jj7rjyyfxUigrtxA4fMRKf
…ream Compared updateTexture against the current imgui_impl_opengl3.cpp ImGui_ImplOpenGL3_UpdateTexture. Upstream backs up GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT on entry and restores them on exit; the port previously set them without restoring, breaking the backend's back-up/restore-all-GL-state contract for hosts with non-default unpack state. Mirror upstream exactly: save both, set ALIGNMENT=1, set ROW_LENGTH=0 in WantCreate / =width in WantUpdates, then restore both. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jj7rjyyfxUigrtxA4fMRKf
|
Thanks for the contribution - solid amount of work 👍 Two things I'd like addressed before merging:
|
|
Alright done. Also, the codegen decided to mess with TextEditor for some reason. I'm not sure what's up with that. Should I revert it? |
Added bindings for ImGui's new texture-management API:
ImTextureData,ImTextureRect,ImTextureStatus, plus the relevant accessors.Additionally:
ImGuiImplG13) to use the new dynamic font renderingNotes: