Closed kode54 closed 2 years ago
Afaik support for ARM64 (Windows and macOS) should be available when LWJGL3 v 3.3.0 released. It is in Early Access. You can get it from here if you want to give it a try: https://www.lwjgl.org/download
More details: https://github.com/LWJGL/lwjgl3/issues/601
In order for JME to load the correct natives, we'll need to add a new value to com.jme3.system.Platform
and add cases to JmeSystemDelegate.is64Bit()
and JmeSystemDelegate.getPlatform()
to recognize such systems.
@kode54, what are typical values of System.getProperty("os.name")
and System.getProperty("os.arch")
on arm64 Apple Silicon Macs? (These may be obtained by entering "java -XshowSettings:all" at a shell prompt.)
Oh, I see. You are right.
os.arch = aarch64
os.name = Mac OS X
It looks like the windows arm64 os.arch
is set to aarch64
in the jdk.
https://github.com/openjdk/jdk/blob/bebfae48e3f1643f2456d680d170dcc22f7231bf/src/java.base/windows/native/libjava/java_props_md.c#L574
The os.name
does not look like it gets modified at all.
EDIT: I dare make the assumption that it does not get changed in other third party builds like adoptjdk. But if the code says aarch64
, and that is what we are seeing on MacOS, I would assume that is correct.
I'll extend PR #1530 appropriately.
@tlf30 Maybe you could tell me where I could find a native aarch64 build of openjdk for Windows? I could test things there as well, when the time comes.
A pre-release build can be found here: https://github.com/microsoft/openjdk-aarch64/releases/tag/jdk-16.0.1-ga
The MacOSX_ARM64
platform is now defined in "master" branch. When LWJGL 3.3 goes to General Availability, it should be simple to add support to JME.
LWJGL 3.3.0 was released today!
@kode54, in order to make this happen in the next release (3.5), we need help with testing. Are you still willing and able to test, and if so, which platforms?
I literally don't even remember what project I was attempting to build for someone that needed this. Sorry I can't be more help in that department.
I do have an M1 Mac I can test on, but I don't have anything that actually uses this in mind, so I'd have to look for something to test it.
JMonkeyEngine includes hundreds of examples and test apps in its jme3-examples sub-project, but I'm not asking you to run all of them. Just knowing whether JME can render a blue cube on an Apple M1 would take a load of anxiety off my mind. If you're motivated to do more, I can suggest tests for keyboard/mouse input, audio output, and physics.
I will be attempting to build some of the example apps with JDK 17 (Azul Zulu runtime) on macOS 12.1 beta 3, using Xcode 13 for any natives if I need to build anything there. Let me know if I should adjust my target to something different. OS isn't much of an option since I don't intend to go through downgrading again.
Edit 1: Looks like Java 17 is too new for this. Guess I'll just uninstall that and try Microsoft's 16.0.1. As a bonus, maybe it will even be self updating!
Edit 2: Ah, nope, Microsoft's Java is only for Windows and Linux. Azul Java 15 it is, then.
JME should work with Java 17, though you'll probably get warnings at compile time and runtime. Currently there's no JME build that includes the LWJGL natives for macOS-on-ARM. Also, JME probably doesn't know which natives to extract for that platform.
If you're serious about testing, I'll publish an alpha2 build with the changes I think are needed.
Nope, not gonna do this. IntelliJ wants me to install Android NDK because it thinks this is an Android platform. None of the examples offered by the wiki are newer than 6+ years old.
We're going to need macOS-on-ARM support eventually.
@kode54 and whomever will try this. The Android NDK thing. You can work around this with:
Furthermore, release testing can use the compiled ZIP archive, so there's no need for an IDE on the test system.
There's a compiled ZIP archive for macOS-on-ARM?
There will be one for v3.5.0-alpha2 if someone agrees to test it.
@riccardobl shall I re-assign this issue to you?
Sure
Tested and added with de2e2d38c8622dac588d414ab6fb89efee7bfb6a
Needs Java 11
Recent discussion of minimum java version: https://hub.jmonkeyengine.org/t/jme3-minimum-java-version/45111
@riccardobl @stephengold I really appreciate you guys keeping this up to date. I just happen to be switching to an M1 mac and ran into this. I've built master 3.6 locally and tried to boot up a blue cube, but I still get
Exception in thread "jME3 Main" java.lang.UnsatisfiedLinkError: The required native library 'openal' is not available for your OS: MacOSX_ARM64
What am I missing?
M
I need more informations. How are you building the master branch? How are you using the built artifacts? Are you sure you are including them correctly in your project?
I modified the gradle.properties file of JME master like so:
buildNativeProjects = true
buildAndroidExamples = false
buildForPlatforms = Linux64,Linux32,Windows64,Windows32,Mac64
skipPrebuildLibraries=true
I then ran ./gradlew clean build publishToMavenLocal
In another project I included the dependencies like so:
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation "org.jmonkeyengine:jme3-core:3.6.0-SNAPSHOT"
implementation "org.jmonkeyengine:jme3-desktop:3.6.0-SNAPSHOT"
implementation "org.jmonkeyengine:jme3-lwjgl:3.6.0-SNAPSHOT"
}
Followed up with a Java Main class like so
package com.appliedvillainy.jme;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
AppSettings settings = new AppSettings(true);
settings.setTitle("My Awesome Game");
app.setSettings(settings);
app.start();
}
@Override
public void simpleInitApp() {
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
}
You need lwjgl3 on M1, lwjgl2 is not supported.
Can you try to change this line
implementation "org.jmonkeyengine:jme3-lwjgl:3.6.0-SNAPSHOT"
to
implementation "org.jmonkeyengine:jme3-lwjgl3:3.6.0-SNAPSHOT"
and see if it works?
That seems to have worked.. although for some reason, the show settings dialog won't show and the system hangs without error.
app.setShowSettings(false)
Allows a basic jme hello world to show up using the JDK 17.0.2 (arm64) "Eclipse Temurin"
Thanks for your help.
Mark
That seems to have worked.. although for some reason, the show settings dialog won't show and the system hangs without error.
Yes, that's a known issue with macos and lwjgl3, we will include a workaround or fix in the future releases, for now you can disable it, as you did, and configure your app in code before calling start(), like so:
AppSettings settings=new AppSettings(true);
settings.setXXXX
app.setSettings(settings);
Allows a basic jme hello world to show up using the JDK 17.0.2 (arm64) "Eclipse Temurin"
Thanks for your help.
Wonderful, feel free to open new issues or ask on the forum if you need more help
Native library support can be expanded to include arm64 support for Apple Silicon Macs. The architecture name starts with "arm", and there is no 32 bit to support on macOS ARM. I already have tested lwjgl built for fat binaries, for use with Minecraft, it only required either Azul's Zulu builds of Java, or possibly Amazon's builds, but I haven't tested the latter.
I tried an existing built application jar with the arm64 java, but obviously, it failed when it unpacked its i386/x86_64 libopenal.dylib and couldn't load it. Technically, you can even use lipo to bundle the ppc32 and ppc64 builds into it as well? Or does arm64 supporting lipo disable support for even i386? I guess that could mean that those get bundled into yet another binary in the jar.