CreedVI / Raylib-J

Handmade Java binding for Raylib
zlib License
94 stars 16 forks source link

Initialization fails on MacOS 12.5 (Intel) #37

Closed s-wallace closed 5 months ago

s-wallace commented 2 years ago

Describe the bug Using the existing RayLib-J_DEV-0.5.jar as the only dependency, initialization of rCore fails with UnsatisfiedLinkError in InitGraphicsDevice on the call GLFW.glfwSetErrorCallback(new com.raylib.java.core.Callbacks.ErrorCallback());

To Reproduce Steps to reproduce the behavior:

  1. Build the Raylib-J-Examples (e.g., InputKeys), putting RayLib-J_DEV-0.5.jar on the classpath
  2. Run the demo with -Dorg.lwjgl.util.Debug=true -Dorg.lwjgl.util.DebugLoader=true
  3. See error in console output

Expected behavior Running application

Console output

[LWJGL] Version: 3.2.3 SNAPSHOT
[LWJGL]      OS: Mac OS X v12.5
[LWJGL]     JRE: 17.0.3 x86_64
[LWJGL]     JVM: Java HotSpot(TM) 64-Bit Server VM v17.0.3+8-LTS-111 by Oracle Corporation
[LWJGL] Loading JNI library: lwjgl
[LWJGL]     Module: org.lwjgl
[LWJGL]     Using SharedLibraryLoader...
[LWJGL]     Found at: /var/folders/c5/j4nj67xx60v19vf_38wmsnl00000gn/T/3.2.3-SNAPSHOT/liblwjgl.dylib
[LWJGL]     Loaded from org.lwjgl.librarypath: /var/folders/c5/j4nj67xx60v19vf_38wmsnl00000gn/T/3.2.3-SNAPSHOT/liblwjgl.dylib
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'long org.lwjgl.system.Callback.getNativeCallbacks(java.lang.reflect.Method[], long)'
    at org.lwjgl.system.Callback.getNativeCallbacks(Native Method)
    at org.lwjgl.system.Callback.<clinit>(Callback.java:59)
    at com.raylib.java.core.rCore.InitGraphicsDevice(rCore.java:2313)
    at com.raylib.java.core.rCore.InitWindow(rCore.java:160)
    at core.InputKeys.main(InputKeys.java:34)

Partial Remediation Adding lwjgl 3.2.3 to the classpath ahead of RayLib-J_DEV-0.5.jar will resolve the LinkError, however, in this case there appears to be an issue with the screen coordinate system (see screenshot below).

Screen Shot 2022-09-21 at 10 42 24 AM

Environment

CreedVI commented 2 years ago

I was unable to recreate your issue with the linker error on my machine, so that may be an issue with the OSX lwjgl natives I included in the Raylib-J build.

As for the screenshot you provided, that may be another OSX specific bug with window scaling/high dpi. That's just an initial hunch though.

I do not own any apple devices, so I cannot test anything on my end.

s-wallace commented 2 years ago

Thanks for the follow up! Yes, I think the high DPI issue is something LWJGL+OSX specific. I'll try to follow up by looking through their issue log; it seems keeping some sort of reference with Raylib-J may help people avoid all the detective work in the future.

-Scott

On Wed, Sep 21, 2022 at 11:05 AM Calvin Day @.***> wrote:

I was unable to recreate your issue with the linker error on my machine, so that may be an issue with the OSX lwjgl natives I included in the Raylib-J build.

As for the screenshot you provided, that may be another OSX specific bug with window scaling/high dpi. That's just an initial hunch though.

I do not own any apple devices, so I cannot test anything on my end.

— Reply to this email directly, view it on GitHub https://github.com/CreedVI/Raylib-J/issues/37#issuecomment-1254052976, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJCPVZNGMITQQH2KQCHKUTV7NE6XANCNFSM6AAAAAAQSJTH5M . You are receiving this because you authored the thread.Message ID: @.***>

CreedVI commented 2 years ago

I'd recommend trying to enable the HIGH_DPI config flag:

        rlj.core.SetWindowState(Config.ConfigFlag.FLAG_WINDOW_HIGHDPI);