Login  Register

Re: How to make screenshot on SWT

Posted by gouessej on Jun 10, 2015; 11:11am
URL: https://forum.jogamp.org/How-to-make-screenshot-on-SWT-tp4033448p4034632.html

Which compilation errors do you fail to fix when you use com.jogamp.opengl.swt.GLCanvas? It extends org.eclipse.swt.widgets.Canvas, you only have to replace a few OpenGL related things. You can call getContext() to get the OpenGL context of the canvas. Then, you can call makeCurrent() and release() on this context. However, making an OpenGL context current on different threads is a bit dangerous, it might fail with numerous drivers :s Rather use GLAutoDrawable.invoke() to enqueue OpenGL tasks. It would be even better to perform your OpenGL calls only directly or indirectly in GLEventListener.display(), it would be a lot safer and less error prone.

If you use com.jogamp.opengl.awt.GLCanvas, you'll need to use the bridge I mentioned earlier:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fawt%2FSWT_AWT.html
but it won't give you a SWT Canvas.

The AWT GLCanvas extends the AWT Canvas, the same methods are still available. It's similar for the JOGL SWT GLCanvas.
Julien Gouesse | Personal blog | Website