Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos support #3

Open
shahabqamar opened this issue Jan 7, 2023 · 5 comments
Open

macos support #3

shahabqamar opened this issue Jan 7, 2023 · 5 comments

Comments

@shahabqamar
Copy link

Hi, thank you for making this awesome program!

I would like to know if there is a way to run this program on macos.

Cheers

@tom-mohr
Copy link
Owner

tom-mohr commented Jan 8, 2023

Hi, thank you! Currently not. It's theoretically possible, it only requires some configuration of the build process. But I don't have a Mac, so the only chance for this to happen is if someone else does it. I will gladly merge any pull request that provides support for MacOS. It seems like there will be Linux support soon, so maybe MacOS isn't too far away.
Greetings

@shahabqamar
Copy link
Author

Got it. Just had a quick look at the pull request for linux support.

It appears to check for macos:
#4
d7941f7#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7R73

I tested updated my local build.gradle file to see if it works on macos but still throwing errors:

> Task :run FAILED
Using LWJGL 3.3.0 3.3.0
Exception in thread "main" java.lang.ExceptionInInitializerError
        at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1046)
        at com.particle_life.app.App.init(App.java:102)
        at com.particle_life.app.App.launch(App.java:39)
        at com.particle_life.app.Main.main(Main.java:38)
Caused by: java.lang.IllegalStateException: GLFW may only be used on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.
        at org.lwjgl.glfw.EventLoop.<clinit>(EventLoop.java:30)
        ... 4 more

@noob10293
Copy link

have you tried running the JVM with -XstartOnFirstThread?

@vtnil
Copy link

vtnil commented May 2, 2023

I have been running on Mac m1 successfully. The main problem base on the two library lwjgl and imgui.
I changed my build.gradle file like this:

 ...

 10
 11 application {
 12     mainClass = "com.particle_life.app.Main"  // required for "run" task
 13
 14     if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
 15         applicationDefaultJvmArgs = ["-XstartOnFirstThread", '-Djava.awt.headless=true']
 16     }
 17     try {
 18         if (libPath) {
 19             applicationDefaultJvmArgs += ["-Dimgui.library.path=$libPath"]
 20         }
 21     } catch (ignored) {
 22         // ignore
 23     }
 24 }
 25

...

110     processResources.exclude('*')
111 }
112
113 // project.ext.lwjglVersion = "3.3.0"
114 project.ext.lwjglVersion = "3.3.0-SNAPSHOT"
115 project.ext.lwjglNatives = "natives-macos-arm64"
116
117 switch (OperatingSystem.current()) {
118     case OperatingSystem.LINUX:

...

158     implementation "com.github.tom-ski.imgui-java:imgui-java-app:v1.86.2"
159
160     // LWJGL
161     // see https://www.lwjgl.org/customize for a list of all available contents
162 //    [".lwjgl", ".glfw", ".opengl"].each {
163 //        implementation "org.lwjgl.osgi:org.lwjgl$it:$lwjglVersion"
164 //    }
165
166     implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
167     implementation "org.lwjgl:lwjgl"
168     implementation "org.lwjgl:lwjgl-glfw"
169     implementation "org.lwjgl:lwjgl-opengl"
170     runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
171     runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
172     runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"

Then compile imgui-java for M1 from this repo: https://github.com/Tom-Ski/imgui-java

Finally, Im running with my local imgui-java like this:

./gradlew run -PlibPath=../imgui-java/imgui-binding/build/libsNative/macosxarm64

have fun~

Last but not least ! Im running on Java17

@tom-mohr
Copy link
Owner

tom-mohr commented May 2, 2023

Awesome! Could you imagine turning this into a pull request? This would require automating this in the build.gradle so that M1 users don't have to compile imgui-java by hand and don't need to explicitly specify the -PlibPath argument. They should just be able to do ./gradlew run.
And if someone else is reading this, feel free to do this and create a PR!!
I think it would be very appreciated by M1 users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants