SpaiR / imgui-java

JNI based binding for Dear ImGui
MIT License
551 stars 90 forks source link

Fix nullpointer exception when running with LWJGLX-debug #147

Closed theVerySharpFlat closed 1 year ago

theVerySharpFlat commented 1 year ago

Description

I added a call to this function after platform window creation as it initializes a MAX_VERTEX_ATTRIBS variable for the current OpenGL context which is then used as a size for the creation of an array which is accessed here. When this function isn't called, the length of the array is zero and thus this function call throws an index-out-of-bounds exception.

Note: This only occurs when LWJGLX-debug is used.

Type of change

SpaiR commented 1 year ago

ImGuiImplGlfw is a generally purpose implementation. It is possible to make it to work with other renderes, not only with OpenGL. So, I would like to keep it as it is at the moment. If you really required to call GL#createCapabilities method here, I would recommend to copy the class locally instead.

theVerySharpFlat commented 1 year ago

ImGuiImplGlfw is a generally purpose implementation. It is possible to make it to work with other renderes, not only with OpenGL. So, I would like to keep it as it is at the moment. If you really required to call GL#createCapabilities method here, I would recommend to copy the class locally instead.

My thinking was that, since it helped me, it would help others. However, when I was trying to solve the issue, I didn't find any other people on the internet with the same problem, so I suppose this isn't necessary.

SpaiR commented 1 year ago

I'll close the PR, since of it fixes a specific problem which is not applicable to a general use case. Still, I believe it will be helpful to other people which will meet this problem. 👍