-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: game of Pong with JBang, Java and LWJGL #15
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
base: main
Are you sure you want to change the base?
Conversation
examples/game/Pong.java
Outdated
| //DEPS org.lwjgl:lwjgl:3.3.3 | ||
| //DEPS org.lwjgl:lwjgl-glfw:3.3.3 | ||
| //DEPS org.lwjgl:lwjgl-opengl:3.3.3 | ||
| //DEPS org.lwjgl:lwjgl:3.3.3:natives-windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure that kind of deps resolution does what you hope for...only one of org.lwjgl:* artifacts will get included...first one wins.
I think that explains why I get :
jbang examples/game/Pong.java
[jbang] Resolving dependencies...
[jbang] org.lwjgl:lwjgl:3.3.3
[jbang] org.lwjgl:lwjgl-glfw:3.3.3
[jbang] org.lwjgl:lwjgl-opengl:3.3.3
[jbang] Dependencies resolved
[jbang] Building jar for Pong.java...
[LWJGL] Platform/architecture mismatch detected for module: org.lwjgl
JVM platform: macOS aarch64 21.0.7
OpenJDK 64-Bit Server VM v21.0.7+6-LTS by Eclipse Adoptium
Platforms available on classpath:
windows/x64
linux/x64
macos/x64
[LWJGL] Failed to load a library. Possible solutions:
a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
b) Add the JAR that contains the shared library to the classpath.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: liblwjgl.dylib
at org.lwjgl.system.Library.loadSystem(Library.java:174)
at org.lwjgl.system.Library.loadSystem(Library.java:64)
at org.lwjgl.system.Library.<clinit>(Library.java:52)
at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:100)
at org.lwjgl.system.Pointer$Default.<clinit>(Pointer.java:67)
at org.lwjgl.system.Callback.<clinit>(Callback.java:40)
at Pong.init(Pong.java:79)
at Pong.run(Pong.java:64)
at Pong.main(Pong.java:280)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're running on macOS aarch64 which is not currently supported by the Pong.java program.
Platforms available via the classpath as reported by the runtime are:
- windows/x64
- linux/x64
- macos/x64
I'll check if a native library for aarch64 is available.
|
love it - did you make the game or copied from somewhere? should make ref if from somewhere else. we'll need to figure out how to do the deps in a portable way. |
|
This game was developed from scratch using Google Gemini AI. I tested the game on Linux and Windows, had to a make a small timing change so that Linux was properly supported. |
It should work now on macOS (arm64) as well. |
|
i gets further but errors with: i can make it work using this:
not sure if adding //RUNTIME_OPTIONS -XstartOnFirstThread` to it will have bad impact on windows/linux? |
|
btw. i'm surprised the fix worked ...trying to grok if bug or feature :) |
|
remarkably fatjar of that is "only 3.7mb... |
|
I've disabled the main thread check using runtime option -Dorg.lwjgl.glfw.checkThread0=false. @maxandersen , please check if this resolves the macOS issue. |
|
I no longer get an error but now it just hangs/doing nothing.
what error are you getting on windows? |
|
There currently is no way to get this to work without explicitly specifying the will set the heap size to 2GB for all platforms and only on MacOS also add option -XstartOnFirstThread One could extend this to also allow specifying an optional ARCH_TYPE as well, but it I'm not quite sure if that's really needed.
Comments? |
|
Similar issue for //DEPS we might want to consider {key=value} being applicable to directives ... At least to things like runtime options. |
|
Moved the JBang directives to file Config.java. //usr/bin/env jbang "$0" "$@" ; exit $?
// Game developed using Google Gemini AI (2.5 Pro)
//SOURCES Config.java
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import org.lwjgl.system.*;
... |
|
Why? You plan to share that Config.java between multiple games in this repo or how? |
It was an experiment. Reverted the change again. |
$ jbang run Pong.java