I am working on a 3D visualization tool as a prototype desktop app in Java/Kotlin.
I need the GUI power of JavaFX or Compose for Desktop (or Swing, worst case) but I need the main panel of the window to be a high performance dynamic 3D graphics using LibGDX, JOGL or similar low-level library.
I have searched many SO posts and pages but found no way to do this so far.
Can anyone suggest the best way to embed a 3D panel into one of the big desktop GUI frameworks? Or a demo repo which does this already?
I managed to create a solution on the stack:
I got it working by following these steps:
Use the LibGDX setup wizard with settings:
Modify build.gradle line:
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"to
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"Convert DesktopLauncher to Kotlin code in IntelliJ (open file, Ctrl+Alt+Shift+K):
Replace DesktopLauncher code with:
https://github.com/brendanhillovida/try-libgdx-kotlin-gradle-swing
Notes:
I don't know why the wizard didn't create DesktopLauncher and MyGdxGame in Kotlin after specifying Kotlin as the language - but it is easy to auto-convert
It appears that LibGDX cannot use LWJGL3 as the backend if you want to embed in Swing (various pages mentioned this, I didn't research further what the latest status is)
There appear to be viable options using JavaFX however my preference is Swing and I got it to work, so I didn't investigate them further.