SpaiR / imgui-java

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

ARM64 native binaries for MacOS #190

Open zbx1425 opened 11 months ago

zbx1425 commented 11 months ago

Description

This PR attempts to finish #112 by merging it with the latest upstream updates and trying tofix the build scripts. Now the CI script can produce correct binary files. I have yet to test if these native binaries built actually works currently though.

Type of change

kusaanko commented 10 months ago

I don't think this has a problem. I built this repository and published it to my local maven repository. Then I run the example code on my test gradle project. It works with arm64 JVM. I tested it on M2 MacBook Air. image

manmaor commented 10 months ago

@SpaiR Hi, could you please merge this PR, It will be greatly appreciated, Much obliged, Maor.

eclogues commented 10 months ago

Excitedly waiting for this to be merged.

LawrenceB5477 commented 9 months ago

Any update on this? Trying to use imgui on my m1

OlshaMB commented 8 months ago

@SpaiR what's stopping this pr?

b7011343 commented 8 months ago

@SpaiR I too would like to know what's stopping this PR

OlshaMB commented 8 months ago

I think the branch needs to be merged with new changes, but apart from that i don't see any issues.

Not related to the pr I came to this pr because it prevents me from playing minecraft with [axiom](https://axiom.moulberry.com/), I had to provide the libs by path.

I think if the author won't merge someone should maintain the fork and release the mac m-series version, this fork should also have a guide for providing the forked version to a java program. At the moment, I am too busy.

OlshaMB commented 8 months ago

@zbx1425 Could you merge or give rights to @b7011343 or me to the fork, so we wouldn't have to make an another pr

zbx1425 commented 8 months ago

I think if the author won't merge someone should maintain the fork and release the mac m-series version, this fork should also have a guide for providing the forked version to a java program. At the moment, I am too busy.

I see there's workflows in the repo for releasing built bindings and natives to maven. But I'm new to gradle and maven, so I'd appreciate helps on getting it working on forked repository.

realRobotix commented 7 months ago

@zbx1425 i've forked your fork, merged changes from upstream and setup the workflows to publish to my maven repo: https://maven.realrobotix.me/#/imgui-java/io/github/spair https://github.com/realRobotix/imgui-java would be nice if someone could test the macos artifacts the build produced

bionicode commented 7 months ago

would be nice if someone could test the macos artifacts the build produced

Wow, this works! Thanks!!! @realRobotix. I'm on an M1 MacBook Pro running Sonoma.

b7011343 commented 7 months ago

How do I use this dependency in a gradle project? I know i have to point it at the maven repo but I keep having build errors

bionicode commented 7 months ago

How do I use this dependency in a gradle project? I know i have to point it at the maven repo but I keep having build errors

This worked for me.

project.ext.lwjglVersion = "3.3.3" project.ext.lwjglNatives = "natives-macos-arm64"

repositories {

maven {
    name "realrobotixImguiJava"
    url "https://maven.realrobotix.me/imgui-java"
}

mavenCentral()

}

dependencies {

// Imgui fork at real robotix
implementation "io.github.spair:imgui-java-app:1.86.11-10-g0dbf36c"
implementation "io.github.spair:imgui-java-natives-macos-ft:1.86.11-10-g0dbf36c"

// LWJGL
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-glfw"
implementation "org.lwjgl:lwjgl-opengl"
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"

}

b7011343 commented 7 months ago

I am getting build errors with the following build.gradle


repositories {
//    mavenLocal()

    maven {
        name "realrobotixImguiJava"
        url "https://maven.realrobotix.me/imgui-java"
    }

    mavenCentral()
}

project.ext.lwjglVersion = "3.3.3"
project.ext.jomlVersion = "1.10.5"
project.ext.imguiVersion = "1.82.2"

switch (OperatingSystem.current()) {
    case OperatingSystem.LINUX:
        def osArch = System.getProperty("os.arch")
        project.ext.lwjglNatives = osArch.startsWith("arm") || osArch.startsWith("aarch64")
                ? "natives-linux-${osArch.contains("64") || osArch.startsWith("armv8") ? "arm64" : "arm32"}"
                : "natives-linux"
        break
    case OperatingSystem.MAC_OS:
        project.ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
        break
    case OperatingSystem.WINDOWS:
        def osArch = System.getProperty("os.arch")
        project.ext.lwjglNatives = osArch.contains("64")
                ? "natives-windows${osArch.startsWith("aarch64") ? "-arm64" : ""}"
                : "natives-windows-x86"
        break
}

project.ext.lwjglNatives = "natives-macos-arm64"

dependencies {
    implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

    ['', '-opengl', '-glfw'].each {
        implementation "org.lwjgl:lwjgl$it:$lwjglVersion"
        implementation "org.lwjgl:lwjgl$it::natives-windows"
    }

    implementation "io.github.spair:imgui-java-binding:$imguiVersion"
    implementation "io.github.spair:imgui-java-lwjgl3:$imguiVersion"

    implementation "io.github.spair:imgui-java-natives-windows:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-windows-x86:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-linux:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-linux-x86:$imguiVersion"
//    implementation "io.github.spair:imgui-java-natives-macos:$imguiVersion"
    implementation "io.github.spair:imgui-java-natives-macos-ft:1.86.11-10-g0dbf36c"
    implementation "io.github.spair:imgui-java-app:1.86.11-10-g0dbf36c"
//    implementation "io.github.spair:imgui-java-natives-macos:1.86.11-10-g0dbf36c"
//    implementation "io.github.spair:imgui-java-natives-macosarm64"

    implementation "org.lwjgl:lwjgl"
    implementation "org.lwjgl:lwjgl-assimp"
    implementation "org.lwjgl:lwjgl-glfw"
    implementation "org.lwjgl:lwjgl-nfd"
    implementation "org.lwjgl:lwjgl-openal"
    implementation "org.lwjgl:lwjgl-opengl"
    implementation "org.lwjgl:lwjgl-stb"
    runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-nfd::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
    implementation "org.joml:joml:${jomlVersion}"

Error


Exception in thread "main" java.lang.IllegalStateException: Failed to compile shader:
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: '330' : syntax error: syntax error

        at imgui.gl3.ImGuiImplGl3.createAndCompileShader(ImGuiImplGl3.java:463)
        at imgui.gl3.ImGuiImplGl3.createShaders(ImGuiImplGl3.java:313)
        at imgui.gl3.ImGuiImplGl3.createDeviceObjects(ImGuiImplGl3.java:272)
        at imgui.gl3.ImGuiImplGl3.init(ImGuiImplGl3.java:127)
        at jcw.jge2d.engine.gui.ImGuiLayer.initImGui(ImGuiLayer.java:233)
        at jcw.jge2d.engine.gui.Window.init(Window.java:187)
        at jcw.jge2d.engine.gui.Window.run(Window.java:117)
        at jcw.jge2d.Main.main(Main.java:9)
Christoffyw commented 6 months ago

Would be nice if this was merged.

Displee commented 2 months ago

Can this be merged?

zly2006 commented 1 month ago

@SpaiR I have reverted some unnecessary changes so it could be merged, and the example app works fine for me, but there is still something to do:

phraktle commented 1 day ago

@SpaiR It would be great to get this (or #223 if that's better) merged and released (since the @realRobotix maven repo is not functional).

realRobotix commented 1 day ago

@SpaiR It would be great to get this (or #223 if that's better) merged and released (since the @realRobotix maven repo is not functional).

sorry for the inconvenience, i have identified the issue with the maven it should be up again in a few minutes