kotlin-graphics/imgui

Broken dependencies adding imgui to a minecraft project

Closed this issue · 4 comments

I'm trying to create a fabric (minecraft mod environment) mod for minecraft (which uses LWJGL 3.2.1), using fabric's example mod build.gradle.

I'd like to add imgui as a library. However, adding it to the dependencies task like so:

implementation "com.github.kotlin-graphics:imgui:fc9aad3de1"

Will result in a lot of broken dependencies (all LWJGL):
image
(These show up as "FAILED" in the output of the dependencies task)

I presume this is because of the version mismatch between imgui (3.2.2) and minecraft (3.2.1) but, assuming LWJGL uses SemVer, both should be compatible, and we already have LWJGL in our classpath, so I assumed it was safe to exclude LWJGL from imgui:

implementation("com.github.kotlin-graphics:imgui:fc9aad3de1") {
    exclude group: "org.lwjgl"
}

Which, indeed, made the library resolveable:
image

Though, actually using it will yield a NoClassDefFoundError:

private static uno.glfw.glfw glfw = uno.glfw.glfw.INSTANCE;
private static ImGui imgui = ImGui.INSTANCE;
private static ImplGL3 implGl3;

static {
    glfw.init();
    implGl3 = new ImplGL3(); // Exception is thrown here
}
...
[00:08:30] [main/INFO]: [STDOUT]: java.lang.NoClassDefFoundError: gln/identifiers/GlProgram
[00:08:30] [main/INFO]: [STDOUT]: 	at imgui.impl.ImplGL3.<init>(ImplGL3.kt:39)
...

Looking up where gln.identifiers.GlProgram might come from on google, I can only find this repository. What am I doing wrong? Sorry if this is a duplicate of #42.

Thank you in advance.

Hi!

We just went to a multi-project structure in order to allow for multiple rendering backends, and this problem looks related, but I'm not entirely sure what the issue is. My best guess would be that if you are using OpenGL, you should use this code for the ImGui dependency:

ext{
    imguiVersion = "fc9aad3de1"
}

["gl", "glfw", "core"].each {
    implementation("com.github.kotlin-graphics.imgui:imgui-$it:$imguiVersion") {
        exclude group: "org.lwjgl"
    }
}

This will grab the OpenGL branch and everything that it requires, which may fix your problem. If it doesn't, let em know and we'll try some other stuff.

On a side note, LWJLGL does not strictly follow SemVer, so code may break doe to the version difference. I've considered adding LWJGL version checks to use the proper code paths on load, but so far it hasn't seemed worth it.

Yup, that did the trick. Thank you!

@Sylvyrfysh , may it be worth adding that snippet in the README?