Open lokka30 opened 2 years ago
Hi @lokka30
I've added support for macOS ARM64 in pom.xml
However, I have not tested it.
Sweet! I'll test it now.
Unfortunately I still can't compile (following instructions on the README):
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl:jar:natives-macos-arm64 is missing. @ line 131, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-glfw:jar:natives-macos-arm64 is missing. @ line 136, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-opengl:jar:natives-macos-arm64 is missing. @ line 141, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-stb:jar:natives-macos-arm64 is missing. @ line 146, column 21
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.snksynthesis.voxelgame:voxel-game:1.0 (/Users/lach/Documents/Programming/Java/voxel-game/pom.xml) has 4 errors
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl:jar:natives-macos-arm64 is missing. @ line 131, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-glfw:jar:natives-macos-arm64 is missing. @ line 136, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-opengl:jar:natives-macos-arm64 is missing. @ line 141, column 21
[ERROR] 'dependencies.dependency.version' for org.lwjgl:lwjgl-stb:jar:natives-macos-arm64 is missing. @ line 146, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Which JDK are you using?
Which JDK are you using?
lach@LAIR ~ % java -version
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-39)
OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)
:)
Okay :). I've updated pom.xml
to include versions of all LWJGL dependencies.
Ooh, working better now! Encountered a new warning/error:
[WARNING]
java.lang.ExceptionInInitializerError
at org.lwjgl.glfw.GLFW.glfwInit (GLFW.java:1046)
at com.snksynthesis.voxelgame.gfx.Window.create (Window.java:36)
at com.snksynthesis.voxelgame.App.init (App.java:43)
at com.snksynthesis.voxelgame.App.run (App.java:95)
at com.snksynthesis.voxelgame.App.main (App.java:125)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
at java.lang.Thread.run (Thread.java:833)
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)
at org.lwjgl.glfw.GLFW.glfwInit (GLFW.java:1046)
at com.snksynthesis.voxelgame.gfx.Window.create (Window.java:36)
at com.snksynthesis.voxelgame.App.init (App.java:43)
at com.snksynthesis.voxelgame.App.run (App.java:95)
at com.snksynthesis.voxelgame.App.main (App.java:125)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
at java.lang.Thread.run (Thread.java:833)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.038 s
[INFO] Finished at: 2022-03-24T21:59:53+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project voxel-game: An exception occured while executing the Java class. null: ExceptionInInitializerError: 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. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Okay that's better. Based on https://www.lwjgl.org/guide, MacOS users have to add the option: -XstartOnFirstThread
. I've updated the README.md to include that.
Another step closer! But now a new error. π£
lach@LAIR voxel-game % java -XstartOnFirstThread -jar ./target/voxel-game-1.0.jar
java.io.FileNotFoundException: ile:/Users/lach/Documents/Programming/Java/voxel-game/target/voxel-game-1.0.jar!/shaders/vertex.glsl (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at java.base/java.util.Scanner.<init>(Scanner.java:639)
at com.snksynthesis.voxelgame.gfx.Shader.readFile(Shader.java:100)
at com.snksynthesis.voxelgame.gfx.Shader.createShader(Shader.java:80)
at com.snksynthesis.voxelgame.gfx.Shader.link(Shader.java:43)
at com.snksynthesis.voxelgame.App.init(App.java:47)
at com.snksynthesis.voxelgame.App.run(App.java:95)
at com.snksynthesis.voxelgame.App.main(App.java:125)
java.io.FileNotFoundException: ile:/Users/lach/Documents/Programming/Java/voxel-game/target/voxel-game-1.0.jar!/shaders/fragment.glsl (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at java.base/java.util.Scanner.<init>(Scanner.java:639)
at com.snksynthesis.voxelgame.gfx.Shader.readFile(Shader.java:100)
at com.snksynthesis.voxelgame.gfx.Shader.createShader(Shader.java:80)
at com.snksynthesis.voxelgame.gfx.Shader.link(Shader.java:44)
at com.snksynthesis.voxelgame.App.init(App.java:47)
at com.snksynthesis.voxelgame.App.run(App.java:95)
at com.snksynthesis.voxelgame.App.main(App.java:125)
java.lang.Exception: Error linking shader: ERROR: Compiled vertex shader was corrupt.
ERROR: Compiled fragment shader was corrupt.
at com.snksynthesis.voxelgame.gfx.Shader.link(Shader.java:48)
at com.snksynthesis.voxelgame.App.init(App.java:47)
at com.snksynthesis.voxelgame.App.run(App.java:95)
at com.snksynthesis.voxelgame.App.main(App.java:125)
Exception in thread "main" java.lang.RuntimeException: Couldn't load texture!
at com.snksynthesis.voxelgame.texture.Texture.<init>(Texture.java:45)
at com.snksynthesis.voxelgame.texture.Texture.loadRGBA(Texture.java:66)
at com.snksynthesis.voxelgame.chunk.Chunk.<init>(Chunk.java:55)
at com.snksynthesis.voxelgame.chunk.ChunkManager.setVisibleChunks(ChunkManager.java:87)
at com.snksynthesis.voxelgame.chunk.ChunkManager.setCamPos(ChunkManager.java:99)
at com.snksynthesis.voxelgame.App.update(App.java:89)
at com.snksynthesis.voxelgame.App.run(App.java:100)
at com.snksynthesis.voxelgame.App.main(App.java:125)
I would also like to add - on macOS we need to skip the ./mvnw compile exec:java
step as afaik we can't parse JVM arguments into that command. I used ./mvnw clean package
and java -Xstart... -jar ...
to compile and run it.
Good point, thanks, I've updated the README to include that. I got the same error on Windows. It looks like that loading textures wasn't working with the compiled JAR file. I've fixed it (tested on Windows).
Thanks! Another step forward :)
lach@LAIR voxel-game % java -XstartOnFirstThread -jar target/voxel-game-1.0.jar
java.lang.Exception: Error creating shader: ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:3: 'layout' : syntax error: syntax error
at com.snksynthesis.voxelgame.gfx.Shader.createShader(Shader.java:88)
at com.snksynthesis.voxelgame.gfx.Shader.link(Shader.java:42)
at com.snksynthesis.voxelgame.App.init(App.java:47)
at com.snksynthesis.voxelgame.App.run(App.java:95)
at com.snksynthesis.voxelgame.App.main(App.java:125)
FATAL ERROR in native method: Thread[main,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
at org.lwjgl.opengl.GL30C.nglGenVertexArrays(Native Method)
at org.lwjgl.opengl.GL30C.glGenVertexArrays(GL30C.java:2420)
at org.lwjgl.opengl.GL30.glGenVertexArrays(GL30.java:2346)
at com.snksynthesis.voxelgame.gfx.Mesh.<init>(Mesh.java:39)
at com.snksynthesis.voxelgame.chunk.Chunk.genMesh(Chunk.java:310)
at com.snksynthesis.voxelgame.chunk.ChunkManager.update(ChunkManager.java:56)
at com.snksynthesis.voxelgame.App.update(App.java:90)
at com.snksynthesis.voxelgame.App.run(App.java:100)
at com.snksynthesis.voxelgame.App.main(App.java:125)
Would you like me to PR an improvement to the README for Linux/Mac users? - the two platforms seem to have different enough instructions I think they should be separate
That's better :). I've updated window initialization code to support MacOS. Also, I've updated README to separate Mac and Linux instructions.
The instructions are perfect! And, it runs!
Although.. not as we hoped. π
Low framerate and extreme CPU usage, likely also high memory usage as it became slower over time.
By the way, I have no expectation for you to actually work on this issue! As voxel-game is a really neat open-source project, I took interest in trying to improve it through issue documentation and testing. Especially since this particular issue is taking up a lot of your free time for a project with low demand, and on both unpopular hardware and an upopular operating system, feel free to leave this issue alone if you wish. :) I would contribute to the codebase if I knew anything about Java game development, but unfortunately I am only familiar with the programming language itself and not any of these libraries. As I am a student, finding the time to learn these libraries is also not an option. π
Hi @lokka30
π I've made some changes based on the warning that is showing in your terminal when you run the program ("Warning: Validation Failed: ..."). I hope it works now π
Hi @lokka30
π I've made some changes based on the warning that is showing in your terminal when you run the program ("Warning: Validation Failed: ..."). I hope it works now π
Hi, unfortunately I still have the same result as last time. Feel free to give up if you want π otherwise I'm happy to continue testing!
Hi, I am unable to compile voxel-game on macOS ARM64 (M1 MacBook Air):
I tried to solve this myself by adding a macOS ARM64 profile for LWJGL but that was fruitless as I have no idea what I was doing there.