I've been writing software using the LWJGL libraries since around 2013. A few years back, I wanted to upgrade the libraries to use the latest 3.x version. I spent several days swapping out libraries and converting my code to use GLFW windowing. Eventually, nothing would work, so I gave up and switched to the most recenter version of LWJGL2, which was version 2.9.3. I've been stuck here for years.
If you had asked me at the time if I'd recommend LWJGL v3 to a friend, I'd say "Absolutely not!" Why? Well, I don't want my friends to hate me.
A few days ago, I had some extra vacation time, and decided to give LWJGL3 one more try. Surely, most of the early transition phase issues have been resolved, and hopefully the documentation makes it easier to integrate the libraries. But this time, I'd avoid the pain of converting a large existing program, and would instead try working from the ground up. Let's try the basic tutorial and get the libraries to do something... anything... How hard could it be?
I downloaded the stable release version (3.2.2) and started to do a Grade build using Eclipse as the IDE. The documentation make it sound easy to set up a <lwjgl3> library, but with nearly 37 separate libraries, doing that without error is a daunting task. After a couple of fruitless wasted hours, I decided to hand configure a build space. To minimize issues, I elected to get the simple HelloWorld program running without the use of Grade. I'd also use a shell script to ensure that the library setup was simple and correct for both the class path and load libraries.
The first program is the one posted on the 'Get Started' tab. Hey, I've been writing OpenGL code since the '90s, so this simple example should help wring out issues setting up libraries. Alas, no such luck. Hour after hour was spent trying to isolate why a built program wouldn't compile or execute. I remember first learning OpenGL on C/C++, and it was an outright breeze compared to this. I've even considered that it might be easier to just switch languages, at least my code would run faster.
So here I am on day two. I started keeping a journal of all the problems that I ran into and the eventual solutions. Each program solved caused yet-another to be revealed. I've cracked open jar files, scrubbed through .dylibs and done a ton of other work to diagnose where things have gone wrong.
Version 3 has way too many libraries. Version 2.x had a half dozen or so, but dealing with 37 is a bit extreme. I believe that the following set should get the demo code working:
lwjgl, assume, bgfx, glow, nanovg, nuklear, obenan, OpenGL, par, stb and Vulcan.
So here's my 'simple' script:
---------
#!/bin/csh
echo "***** Running HelloWorld w/LWJGL-3.2 *****"
echo " "
echo "[Executing Demo HelloWorld]"
echo " "
setenv LD_LIBRARY_PATH /proj/TestGL3/lib/lwjgl-3.2
setenv DYLD_LIBRARY_PATH /proj/TestGL3/lib/lwjgl-3.2
/usr/bin/java -Xmx1024m -showversion -Djava.library.path="/proj/TestGL/lib/lwjgl-3.2/native/macosx" -cp ../build/classes/java/main:../lib/lwjgl-3.2/lwjgl.jar:../lib/lwjgl-3.2/lwjgl-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-assimp.jar:../lib/lwjgl-3.2/lwjgl-assimp-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-bgfx.jar:../lib/lwjgl-3.2/lwjgl-bgfx-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-glfw.jar:../lib/lwjgl-3.2/lwjgl-glfw-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-nanovg.jar:../lib/lwjgl-3.2/lwjgl-nanovg-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-nuklear.jar:../lib/lwjgl-3.2/lwjgl-nuklear-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-openal.jar:../lib/lwjgl-3.2/lwjgl-openal-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-opengl.jar:../lib/lwjgl-3.2/lwjgl-opengl-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-par.jar:../lib/lwjgl-3.2/lwjgl-par-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-stb.jar:../lib/lwjgl-3.2/lwjgl-stb-natives-macos.jar:../lib/lwjgl-3.2/lwjgl-vulcan.jar:../lib/lwjgl-3.2/lwjgl-vulcan-natives-macos.jar gdemo.HelloWorld
------- EOF------
After spending nearly 16 hours to get to this point, it doesn't work. Here's my current error:
------------
***** Running HelloWorld w/LWJGL-3.2 *****
[Executing Demo HelloWorld]
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
Hello LWJGL 3.2.2 build 10!
2019-06-16 17:46:43.250 java[1364:99471] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
2019-06-16 17:46:43.250 java[1364:99471] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.92/Misc.subproj/NSUndoManager.m:363
2019-06-16 17:46:43.251 java[1364:99471] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.92/Misc.subproj/NSUndoManager.m:363
2019-06-16 17:46:43.252 java[1364:99471] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff8cff994b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffa23f11da objc_exception_throw + 48
2 CoreFoundation 0x00007fff8cffe502 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff8ea65a00 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 Foundation 0x00007fff8e9efeb3 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 170
5 AppKit 0x00007fff8aa584ed -[NSApplication run] + 1200
6 libglfw.dylib 0x00000001262279d5 libglfw.dylib + 68053
7 libglfw.dylib 0x0000000126221366 libglfw.dylib + 41830
8

0x00000001123b5ad0 0x0 + 4600847056
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort
------------
OK, this last ditch attempt at getting LWJGL3 to run has turned into a bust. Lots of time was spent documenting issues with library internals and loading errors. I've wasted an entire long weekend with not even a single polygon or window display to show for it.
If the code had ever started to work, I was planning on uploading the entire folder for others to try. Perhaps a simple working example, even of the most basic form, would be useful in diagnosing issues and ensuring that the libraries could even do the most basic of tasks.
It looks like I'm back to 2.9.3. Stuck again. Maybe 3.3.x or 4.x will be better. Maybe next year will bring better luck.
Tomorrow is another day, and you never know that the tide may bring.
