I'm using the swt GLCanvas (com.jogamp.opengl.swt.GLCanvas) in combination with an Overlay (com.jogamp.opengl.util.awt.Overlay) to display some textual information.
It works fine on Windows, but doesn't work on MacOS because Overlay works with an internal TextureRenderer (com.jogamp.opengl.util.awt.TextureRenderer) which force the use of a GL2 (which is not available on Mac).
My application is designed to work with most recent GL4.
Is there any way to have a GL4 compatible overlay ? I wanted to use the drawing capabilities of SWT graphics, but I'm struggling with the synchronisation of SWT and GL rendering. SWT actions should be done in the main UI thread and I'm not sure how to sync that with every frame of the GLCanvas.
There is a pull request about adding GL3 and GL4 support into com.jogamp.opengl.util.awt.TextureRenderer but it's not integrated into JOGL yet. Either update this contribution to make it work with the latest JOGL version or use the shader based text renderer (see com.jogamp.graph).
I used SWT and Eclipse RCP for years, I advise you to avoid mixing SWT and AWT. The OpenGL rendering of the heayweight com.jogamp.opengl.swt.GLCanvas should be performed on the same thread than the SWT rendering. If you have a doubt, use GLCanvas.invoke().
Thanks for the answer. I'll also would like to avoid mixing SWT and AWT. So contributing to the GL3/4 support in the TextureRenderer is not the solution I4m looking for.
If I understand correctly, the rendering of overlay should be drawn on the SWT GC, right ?
So basically, I should use the GLCanvas.invoke() methods at each frame, which will queue a GLRunnable that will perform the drawing on the SWT component itself ?
If I understand correctly, GLCanvas.invoke() will be a one shot call, so I have to queue it for every frame ?
If you want context, the main display method of my app is visible here
Actually, you shouldn't use the AWT overlay. You can look at the text rendering of other engines based on JOGL to make your own one, for example Jogamp's Ardor3D Continuation that supports SWT and uses JOGL 2.3.2 but its GL4 support isn't heavily tested, it uses PMWMatrix under the hood in some cases including for OpenGL-ES support.
Correct, I'm not trying to use AWT overlay. I want to get rid of the com.jogamp.opengl.util.awt.Overlay.
I would like to draw on the SWT component instead. Not sure if that's what you're talking about.
I'm on the IRC if you have time to discuss it.
You should avoid using com.jogamp.opengl.util.awt.Overlay with SWT.
You should really read the Java documentation of GLCanvas.invoke(). You should post your Runnable after starting your Animator and you should pass "true" to GLCanvas.invoke() if and only if you absolutely need to run the Runnable now and if it doesn't risk to block the rendering.
No, you could simply draw your text with JOGL if possible or with an alternative overlay relying on SWT.
Checking documentation is usually the first thing I do. I looked at the Javadoc of GLCanvas.invoke() but it doesn't help. I tried posting the runnable after and before the animator, with true and false: no success.
I managed to use SWT with a PaintListener, but the paint event on the SWT GLCanvas is not called at each frame. So it gets replaced by the GL content.
I tried attaching a GLEventListener to forward the display event and call a canvas.redraw() in a Display.async/sync, but with this method, it flickers a lot.