Ensure GL device objects before renderDrawData after 1.86→1.87 upgrade - #423
Merged
Merged
Conversation
Since 1.87, ImGuiImplGl3 creates the shader/program/VBO and font texture lazily in newFrame() rather than in init(), matching upstream. Call sites that only call init() + renderDrawData() (the pre-1.87 pattern used by many jME / custom loops) then hit a native NULL dereference inside glDrawElementsBaseVertex. Share the lazy create path with renderDrawData so those upgrades no longer crash. Prefer calling newFrame() every frame; this is a safety net for the upgrade path reported in SpaiR#361. Fixes SpaiR#361
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Since imgui-java 1.87,
ImGuiImplGl3creates the shader/program/VBO and font texture lazily innewFrame()(not ininit()), matching upstreamimgui_impl_opengl3. Integrators that still use the pre-1.87 pattern ofinit()+renderDrawData()withoutnewFrame()then crash in native code (glDrawElementsBaseVertexNULL dereference / EXCEPTION_ACCESS_VIOLATION).This change reuses that lazy create path from
renderDrawData()as a safety net, so the upgrade path reported in #361 no longer hard-crashes the JVM. CallingnewFrame()every frame remains the recommended API.Type of change
Notes for reviewer
newFrame()is skipped;shaderHandle/ buffer handles stay 0 and the draw call faults in the GL driver.imGuiGl3.newFrame()during init (see their jME hub write-up and @Enaium's comment). This patch keeps that recommendation and additionally makesrenderDrawData()self-sufficient for the upgrade path.ensureDeviceObjects()helper shared bynewFrame()/renderDrawData().init/newFrameupdated to document the post-1.87 lazy create.Fixes #361
Test plan
./gradlew :imgui-lwjgl3:compileJava :imgui-lwjgl3:checkstyleMain(JDK 17)./gradlew :example:runwith local natives if desired