Login  Register

Re: How to make screenshot on SWT

Posted by mjamesupc on Jun 09, 2015; 12:04am
URL: https://forum.jogamp.org/How-to-make-screenshot-on-SWT-tp4033448p4034619.html

I am also experiencing this bug, and it is preventing my Eclipse RCP application from exporting a screenshot.   It may or may not be related to how I am using canvases and contexts, but finding the bug filed ( https://jogamp.org/bugzilla/show_bug.cgi?id=1097 ) and discussion here gives me hope that I am using AWTGLReadBufferUtil and BufferedImage correctly.

This is with jogl 2.3.2 and Eclipse SWT GLCanvas, CentOS 6.5 x86_64, and a custom wrapper around GLContext and another for target as GLTarget.


in init():

gl = GLU.getCurrentGL().getGL2();


then in a function     public BufferedImage screenshot():

GLProfile glp = GLProfile.getDefault();
AWTGLReadBufferUtil screenshot = new AWTGLReadBufferUtil(glp, false);
BufferedImage bi = screenshot.readPixelsToBufferedImage(gl, true);



com.jogamp.opengl.GLException: Should not call this
        at jogamp.opengl.x11.glx.X11ExternalGLXContext$Drawable.getSurfaceWidth(X11ExternalGLXContext.java:145)
        at com.jogamp.opengl.util.awt.AWTGLReadBufferUtil.readPixelsToBufferedImage(AWTGLReadBufferUtil.java:94)
        at com.jogamp.opengl.util.awt.AWTGLReadBufferUtil.readPixelsToBufferedImage(AWTGLReadBufferUtil.java:71)
        at com.raytheon.viz.core.gl.internal.GLTarget.screenshot(GLTarget.java:1248)


any insight?



commit from refactoring from jogl 1.1.1 to 2.3.2
https://github.com/Unidata/awips2-core/commit/68392114cfd4ee19a618d3f31c0c6cb404fe6d1e
the screenshot() function:
https://github.com/Unidata/awips2-core/blob/68392114cfd4ee19a618d3f31c0c6cb404fe6d1e/viz/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLTarget.java#L1204
constructor creating and returning CLCanvas for the application to use
https://github.com/Unidata/awips2-core/blob/68392114cfd4ee19a618d3f31c0c6cb404fe6d1e/viz/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/GLContextBridge.java#L101