LWJGL 3 and "non 100% 3D windows"

Started by Estraven, October 08, 2015, 13:11:37

Previous topic - Next topic

Estraven

Hey there

I know LWJGL is designed for games, and thus, menus and such must be integrated within the 3D context.
Yet, I've been using LWJGL 2 for years and I use AWTGLCanvas to create 3D tools with menu, buttons and other panels, where the 3D rendering was only a subpart of the main window.

Is there a way to do this with GLFW? apart from using multiple windows.

Thanks.

spasi

I'm afraid not. You must find a 3rd-party library that provides UI layout & rendering capabilities. There are a few lightweight solutions out there, but I don't think we'll find one popular enough to support in LWJGL out of the box.

LWJGL 3 will never be compatible with AWT. I had hopes for JavaFX integration but it currently suffers from the same issues and there's virtually no interest from OpenJFX/Oracle to make it happen. If there was even a half-decent solution I'd be happy to support it.

The other approach I've explored is integration of a browser engine that supports embedding/offscreen rendering (e.g. CEF). Unfortunately, like JavaFX, the major pain is not having the ability to do it all in the GPU.

You can play with LWJGL-FX to get a sense of the overhead such a solution would have.

Kai

AWT/Swing integration is currently not possible, because AWT/Swing itself does not provide a way to create an OpenGL context.
Therefore, LWJGL 2.x solved this with that custom AWTGLCanvas, which made use of a bunch of methods and platform-dependant native functionality to create such a context.
LWJGL 3 chose to abandon all of this custom OpenGL and window management functions and rely on GLFW instead.
Now, GLFW very unfortunately cannot distinguish/separate between creating a whole window and creating an OpenGL context on a window handle.
Both are tied together. There has been multiple requests for separating this.
See: https://github.com/glfw/glfw/issues/25
But that is still not implemented, as far as I know. So, out of the box, there is no way to integrate AWT/Swing with LWJGL3.
The problems however are not that big. And LWJGL 3 already provides all necessary facilities to revive AWT/Swing support again.
It's just that someone has to do it and provide a new AWTGLCanvas on top of LWJGL3.
And the biggest hurdle for that is to find a platform-independent way to get the window handle of an AWT Canvas.
This itself can be solved with the support library "jawt", included in the JRE.
See: http://stackoverflow.com/questions/386792/in-java-swing-how-do-you-get-a-win32-window-handle-hwnd-reference-to-a-window#answer-413895
That is Windows-only, so also see this: http://stackoverflow.com/questions/24325676/what-does-awt-getdrawingsurface-do
If one gets a hold to that window handle, you can then create a GL context using platform-specific API exposed by LWJGL 3.

Estraven

Alright, I'll deal with it then.
I like the way GLFW works
After all, using two separate windows is not such a big deal.

Thanks for the answers.