Login  Register

Re: GLJPanel for LibGDX JOGL backend

Posted by adam_law on Jul 02, 2015; 10:58pm
URL: https://forum.jogamp.org/GLJPanel-for-LibGDX-JOGL-backend-tp4034741p4034803.html

gouessej wrote
There is no OpenGL context of LibGDX, LibGDX relies on several Java bindings for the OpenGL and OpenGL-ES APIs to manipulate the OpenGL context, it wraps those bindings into a middle level abstraction. I understand that you want to make it work. If you're not yet able to confirm it, check whether GLJPanel really works very well with SwingNode for your use case. If so, check whether JoglSwingCanvas (JogAmp's Ardor3D Continuation) works correctly with SwingNode and if it's the case, porting JoglSwingCanvas to LibGDX will be worth it and I'll do so myself. If you try to solve too many problems at once, you will fail. Make a plain Swing canvas work first and then make it work with JavaFX / OpenJFX, it will help to find the culprit.
Thanks for the explanation. I am new to game development and OpenGL, and I admit that I'm still a bit out of my element at this point.

I think I now understand what you've wanted me to do all along, which is to launch my app within a JOGL window that hosts a GLJPanel (?) Sorry, I admit that I had tunnel-vision on getting the JavaFX aspect to work. I did get my app to work as a JOGLApplication in a GLWindow, so I'm guessing this will turn out well enough on GLJPanel. I'll get to it.

gouessej wrote
I can resurrect the old JoglAWTCanvas and move the current one into JoglNewtAwtCanvas in a few days, this is the least I can do to help you. When it's done, then I'll have you to test them a bit without JavaFX as a first step. After that, I can implement JoglSwingCanvas. Is it ok for you?
This is more than I can ask for, thank you. Sounds good to me :)

Edit #1:

Well that was painless. Running my app using JoglAWTCanvas, putting the NewtCanvasAWT inside a GLJPanel works, and FPS didn't take a hit (my app isn't effects heavy yet).

Putting my app into GLJPanel and adding it to a JDialog window, also had no problems.

I don't think I'll be able to really test SwingNode as well as you suggested, since it's a JavaFX component, which is the heart of the matter. But doing these latest things taught me a couple of new things about reordering stuff so I need not do things like in my previous posts (setting size etc. And I even don't need to set GLContext anymore).

Encouraged by this, I made a JavaFX stage, put in a SwingNode on an AnchorPane layout, and set the SwingNode contents to what worked in run # 1 (JoglAWTCanvas + NewtCanvasAWT + GLJPanel). No errors, and the LibGDX components gets created fine. The LibGDX rendering process loops just fine as well. But on the SwingNode, it only shows a black screen, which resizes correctly, but that's it.