Hello,
if I use lwjgl3 in the manual way I have to set "-Djava.library.path=<dir>/lwjgl_3.0.0a/native" to run the application. How is the recommend way to set this with maven?
See this sample project (https://github.com/badlogic/lwjgl3-maven-gradle), you must use:
SharedLibraryLoader.load();
Please note that, before the official release of LWJGL 3.0, a similar solution will be included in LWJGL.
edit: The above is not required with the latest nightly builds.
Thx. The project takes me one step forward. Now I get "Invalid X server connection specified" and I remember this problem appears if you are working with glfw in the wrong thread. But the demoproject (your link) is not working with threads.
Try the latest nightly build. Use this maven URL: https://oss.sonatype.org/content/repositories/snapshots/ and this LWJGL version: 3.0.0b-SNAPSHOT.
If that doesn't work, make sure OpenGL is working fine on your machine.
3.0.0b-SNAPSHOT does not change the problem, same error. But I tested Lwjgl3Test.java with "LWJGL 3.0.0a build 48 (ZIP)" and it works well.
build #3.0.0b build 9 also works fine.
It sounds similar to this issue (https://github.com/LWJGL/lwjgl3/issues/39). edit: also this one (http://forum.lwjgl.org/index.php?topic=5940.0).
Actually, the latest 3.0.0b-SNAPSHOT doesn't have an "Invalid X server connection specified" error. Are you sure you tested the correct build?
Sorry, my fault. When I use 3.0.0b-SNAPSHOT I can't compile cause GLContext.createFromCurrent(); is not known.
See the latest (http://www.lwjgl.org/guide) getting started guide: you must use GL.createCapabilities().
I changed "GLContext.createFromCurrent()" to "GL.createCapabilities()" and also test the HelloWorld.java example with an additional "SharedLibraryLoader.load()". In both cases I get a NullPointer-Exception:
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.system.Checks.checkPointer(Checks.java:80)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:278)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:230)
at HelloWorld.loop(HelloWorld.java:93)
at HelloWorld.run(HelloWorld.java:26)
at HelloWorld.main(HelloWorld.java:114)
Edit:
Line 93: GL.createCapabilities();
Does it help if you uninstall libgl1-mesa-dev? Also, what GPU do you have?
Removing libgl1-mesa-dev which includes libqt4-opengl-dev and libglu1-mesa-dev helps. Now the examples are working.
GeForce GTS 450
346.82
Linux-x86_64
If it's not too much trouble, could you install libgl1-mesa-dev again, run this code and paste the output here?
System.out.println("contextGLFW = " + GLFWLinux.glfwGetGLXContext(window));
System.out.println("contextLWJGL = " + GLX.glXGetCurrentContext());
long glXGetCurrentDisplay = GL.getFunctionProvider().getFunctionAddress("glXGetCurrentDisplay");
if ( glXGetCurrentDisplay != NULL ) {
long displayGLFW = GLFWLinux.glfwGetX11Display();
long displayLWJGL = JNI.callP(glXGetCurrentDisplay);
System.out.println("displayGLFW = " + displayGLFW);
System.out.println("displayLWJGL = " + displayLWJGL);
} else {
System.out.println("glXGetCurrentDisplay not found.");
}
Add it between glfwMakeContextCurrent(window) and GL.createCapabilities(). There is a good chance that simply reinstalling libgl1-mesa-dev won't reproduce the issue. If that happens, try reinstalling the Nvidia drivers, after libgl1-mesa-dev.
edit: Also, see if mesa adds a "libGL.so.1" symlink anywhere.
contextGLFW = 139802799196784
contextLWJGL = 139802799196784
displayGLFW = 139802798297344
displayLWJGL = 0
I don't see any new symlink to libGL.so.1
There are two new links:
lrwxrwxrwx 1 root root 13 Mär 11 2015 /usr/lib/x86_64-linux-gnu/libGL.so -> mesa/libGL.so
lrwxrwxrwx 1 root root 14 Mär 11 2015 /usr/lib/x86_64-linux-gnu/mesa/libGL.so -> libGL.so.1.2.0
Thanks, I might have an idea for a fix, but will have to wait for a new build.
Quote from: doev on September 15, 2015, 09:50:23There are two new links:
lrwxrwxrwx 1 root root 13 Mär 11 2015 /usr/lib/x86_64-linux-gnu/libGL.so -> mesa/libGL.so
lrwxrwxrwx 1 root root 14 Mär 11 2015 /usr/lib/x86_64-linux-gnu/mesa/libGL.so -> libGL.so.1.2.0
Those shouldn't affect LWJGL, because we load libGL.so.1 (with the .1 postfix). In theory, if you remove those symlinks manually, LWJGL will still fail. Could you confirm please?
- Example is working
- Install libgl1-mesa-dev
- Example fail
- mv /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGL.so_backup
- mv /usr/lib/x86_64-linux-gnu/mesa/libGL.so /usr/lib/x86_64-linux-gnu/mesa/libGL.so_backup
- Example is working
OK, that's weird and very helpful. Thanks for taking the time to test!
More info: LWJGL tries to load libGL.so.1 first, if that fails, it loads libGL.so. I can't check right now, but last time I did on an Ubuntu/Nvidia machine, libGL.so.1 was working fine and loaded the Nvidia implementation. Could you please search if libGL.so.1 is available anywhere? It must be, otherwise GLFW wouldn't work either (it tries libGL.so.1 only).
/usr/lib/nvidia-346/libGL.so.1 -> libGL.so.346.82
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 -> libGL.so.1.2.0
So, there indeed is a mesa symlink for libGL.so.1. Not sure if this is fixable, but I'll let you know when a new build is up to test.
Ok, thx. :)
The new build is up (3.0.0b #27), could you try again please?
edit: If it fails again, please add "-Dorg.lwjgl.util.Debug=true" to the command line and post the output here.
Hey doev, did you have a chance to try it out?
Also, the latest build (3.0.0b #28) includes the SharedLibraryLoader and you don't have to call it explictly, the native libraries are extracted automatically (as long as the JAR that contains them is in the classpath).
Ok, Be aware. DO NOT CALL the example SharedLibraryLoader.load() if you are using the nightly. It breaks everything.
I don't know how to use a specific snapshot version. If I use "3.0.0b-SNAPSHOT" (think that is the latest) the example runs without libgl1-mesa-dev installed but not otherwise.
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.system.Checks.checkPointer(Checks.java:80)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:278)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:230)
at Lwjgl3Test.loop(Lwjgl3Test.java:113)
at Lwjgl3Test.run(Lwjgl3Test.java:28)
at Lwjgl3Test.main(Lwjgl3Test.java:135)
What's the output if you run it with -Dorg.lwjgl.util.Debug=true?
Cause I actually don't know a better way, I started the test with:
java -Dorg.lwjgl.util.Debug=true -cp lwjgl3-tests-1.0-SNAPSHOT-jar-with-dependencies.jar Lwjgl3Test
Lwjgl3Test
[LWJGL] Version 3.0.0b | Linux | amd64
[LWJGL] Loaded library from org.lwjgl.librarypath: liblwjgl.so
Hello LWJGL 3.0.0b!
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libjemalloc.so
[LWJGL] MemoryUtil allocator: JEmallocAllocator
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libglfw.so
[LWJGL] Loaded native library: /usr/lib/x86_64-linux-gnu/libGL.so
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.system.Checks.checkPointer(Checks.java:80)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:278)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:230)
at Lwjgl3Test.loop(Lwjgl3Test.java:113)
at Lwjgl3Test.run(Lwjgl3Test.java:28)
at Lwjgl3Test.main(Lwjgl3Test.java:135)
The output if libgl1-dev is not installed:
Lwjgl3Test
[LWJGL] Version 3.0.0b | Linux | amd64
[LWJGL] Loaded library from org.lwjgl.librarypath: liblwjgl.so
Hello LWJGL 3.0.0b!
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libjemalloc.so
[LWJGL] MemoryUtil allocator: JEmallocAllocator
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libglfw.so
[LWJGL] Loaded native library: libGL.so.1
[LWJGL] Failed to locate address for GL function glNamedBufferPageCommitmentARB
[LWJGL] Failed to locate address for GL function glVertexWeighthNV
[LWJGL] Failed to locate address for GL function glVertexWeighthvNV
A new build is up (#33), could you try again please?
Can I be sure that it is the new build if I have done a clean+build?
[LWJGL] Version 3.0.0b | Linux | amd64
[LWJGL] Loaded library from org.lwjgl.librarypath: liblwjgl.so
Hello LWJGL 3.0.0b!
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libjemalloc.so
[LWJGL] MemoryUtil allocator: JEmallocAllocator
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libglfw.so
[LWJGL] Loaded native library: /usr/lib/x86_64-linux-gnu/libGL.so
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.system.Checks.checkPointer(Checks.java:80)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:278)
at org.lwjgl.opengl.GL.createCapabilities(GL.java:230)
at Lwjgl3Test.loop(Lwjgl3Test.java:113)
at Lwjgl3Test.run(Lwjgl3Test.java:28)
at Lwjgl3Test.main(Lwjgl3Test.java:135)
Based on the output, this appears to not be the latest build. I'll try to include the build number in the version string in future builds.
ls -lah /home/doev/.m2/repository/org/lwjgl/lwjgl/3.0.0b-SNAPSHOT/
insgesamt 5,0M
drwxrwxr-x 2 doev doev 4,0K Sep 22 10:47 .
drwxrwxr-x 9 doev doev 4,0K Sep 22 10:58 ..
-rw-rw-r-- 1 doev doev 1,4M Sep 15 10:41 lwjgl-3.0.0b-20150914.152003-32.jar
-rw-rw-r-- 1 doev doev 40 Sep 15 10:41 lwjgl-3.0.0b-20150914.152003-32.jar.sha1
-rw-rw-r-- 1 doev doev 1019 Sep 15 10:41 lwjgl-3.0.0b-20150914.152003-32.pom
-rw-rw-r-- 1 doev doev 40 Sep 15 10:41 lwjgl-3.0.0b-20150914.152003-32.pom.sha1
-rw-rw-r-- 1 doev doev 1,8M Sep 22 10:47 lwjgl-3.0.0b-20150920.210645-38.jar
-rw-rw-r-- 1 doev doev 40 Sep 22 10:47 lwjgl-3.0.0b-20150920.210645-38.jar.sha1
-rw-rw-r-- 1 doev doev 1019 Sep 22 10:47 lwjgl-3.0.0b-20150920.210645-38.pom
-rw-rw-r-- 1 doev doev 40 Sep 22 10:47 lwjgl-3.0.0b-20150920.210645-38.pom.sha1
-rw-rw-r-- 1 doev doev 1,8M Sep 22 10:47 lwjgl-3.0.0b-SNAPSHOT.jar
-rw-rw-r-- 1 doev doev 1019 Sep 22 10:47 lwjgl-3.0.0b-SNAPSHOT.pom
-rw-rw-r-- 1 doev doev 1,2K Sep 22 10:47 maven-metadata-snapshots-repo.xml
-rw-rw-r-- 1 doev doev 40 Sep 22 10:47 maven-metadata-snapshots-repo.xml.sha1
-rw-rw-r-- 1 doev doev 211 Sep 22 10:47 _maven.repositories
-rw-rw-r-- 1 doev doev 187 Sep 22 10:47 resolver-status.properties
I deleted the local repo and rebuild it. It works now.
lwjgl-3.0.0b-20150922.112323-39.jar
[LWJGL] Version 3.0.0b | Linux | amd64
[LWJGL] Loaded library from org.lwjgl.librarypath: liblwjgl.so
getVersion(): 3.0.0b
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libjemalloc.so
[LWJGL] MemoryUtil allocator: JEmallocAllocator
[LWJGL] Loaded native library: /tmp/lwjgldoev/d0227e9/libglfw.so
[LWJGL] Loaded native library: libGL.so.1
[LWJGL] Failed to locate address for GL function glNamedBufferPageCommitmentARB
[LWJGL] Failed to locate address for GL function glVertexWeighthNV
[LWJGL] Failed to locate address for GL function glVertexWeighthvNV
Awesome, thanks again for testing!