Skip to content

Sync LWJGL backends with ImGui upstream (OpenGL3 + GLFW)#391

Merged
SpaiR merged 2 commits intomainfrom
feat/update-lwjgl-backend
Apr 25, 2026
Merged

Sync LWJGL backends with ImGui upstream (OpenGL3 + GLFW)#391
SpaiR merged 2 commits intomainfrom
feat/update-lwjgl-backend

Conversation

@SpaiR
Copy link
Copy Markdown
Owner

@SpaiR SpaiR commented Apr 25, 2026

Update LWJGL Backend Implementations to Match Recent ImGui C++ Changes

Summary

This PR synchronizes the imgui-java LWJGL backend implementations with the latest Dear ImGui C++ code (commit 32f4c23). The changes modernize OpenGL 3 rendering and GLFW platform integration to support contemporary graphics configurations and improve compatibility across platforms.

Key Changes

ImGuiImplGl3.java:

  • Updated to the latest C++ imgui_impl_opengl3.cpp reference implementation
  • Enhanced OpenGL ES 3.0 profile detection for improved cross-platform support
  • Added runtime GL_MAX_TEXTURE_SIZE querying for proper texture management
  • Introduced feature detection flags (hasPolygonMode, hasBindSampler) for better ES3 compatibility
  • Fixed texture wrapping parameters (GL_CLAMP_TO_EDGE) and pixel alignment settings
  • Added comprehensive comments aligned with upstream C++ structure for maintainability
  • Improved GL state backup/restore logic for compatibility with modern GLFW versions

ImGuiImplGlfw.java:

  • Synchronized with the latest C++ imgui_impl_glfw.cpp reference implementation
  • Added multi-API support (OpenGL, Vulkan, Other) through new initialization methods
  • Implemented runtime Wayland detection to properly gate multi-viewport support on Linux
  • Enhanced key translation including support for GLFW_KEY_WORLD_1 and GLFW_KEY_WORLD_2
  • Fixed mouse cursor state management and added caching to reduce redundant GLFW calls
  • Improved DPI awareness with new helper functions: getContentScaleForWindow() and getContentScaleForMonitor()
  • Added Linux-specific workarounds for mouse event handling during focus loss
  • Updated monitor enumeration logic to handle edge cases (zero DPI, null video modes)
  • Added portable sleep helper function
  • Better platform-specific handling (Windows, macOS, Linux/Wayland) with explanatory comments for Java divergences

Type of change

  • Minor changes or tweaks (quality of life stuff)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

SpaiR and others added 2 commits April 25, 2026 15:13
- Add init overloads for OpenGL, Vulkan, and generic rendering
- Pick up upstream input fixes (GLFW_KEY_WORLD_1/2 mapping, key translation, mouse-leave sentinel)
- Improve monitor tracking: skip zero-size/DPI monitors, preserve list on no-valid-monitor
- Add cursor caching to suppress redundant glfwSetCursor/glfwSetInputMode calls
- Add helpers: isWayland, getContentScaleForWindow/Monitor, getWindowSizeAndFramebufferScale, sleep
- Skip PlatformHasViewports on Wayland
- Fix glfwHawWindowTopmost typo → glfwHasWindowTopmost
- Document intentional omissions (Vulkan, Win32 WndProc, X11 SetWindowFloating, legacy fns)
- Report runtime GLFW version in platform name

Co-authored-by: Claude <noreply@anthropic.com>
…2f4c23)

Mirror upstream capability gating (HasPolygonMode, HasBindSampler, HasClipOrigin,
MaxTextureSize, ES3-on-desktop detection), save/restore order in RenderDrawData,
GL_PIXEL_UNPACK_BUFFER backup in createDeviceObjects, font-texture GL_UNPACK_ALIGNMENT=1
and GL_CLAMP_TO_EDGE wraps, and multi-viewport clear color (0,0,0,1). Intentionally
omitted upstream pieces carry inline comments pointing at follow-up work. Restore the
GLFW framebuffer-scale Linux non-Wayland override (forces 1,1) that was held back
during the earlier GLFW sync.

Co-authored-by: Claude <noreply@anthropic.com>
@SpaiR SpaiR added the chore Routine tasks, refactoring, updates, minor improvements label Apr 25, 2026
@SpaiR SpaiR changed the title Feat/update lwjgl backend Sync LWJGL backends with ImGui upstream (OpenGL3 + GLFW) Apr 25, 2026
@SpaiR SpaiR self-assigned this Apr 25, 2026
@SpaiR SpaiR merged commit c729326 into main Apr 25, 2026
7 checks passed
@SpaiR SpaiR deleted the feat/update-lwjgl-backend branch April 25, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Routine tasks, refactoring, updates, minor improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant