Login  Register

Re: Make screenshot of work display.

Posted by Andriy on Sep 11, 2012; 10:28am
URL: https://forum.jogamp.org/Make-screenshot-of-work-display-tp4026085p4026088.html

Thanks, I use this class but I have an error :

Exception in thread "main" javax.media.opengl.GLException: No OpenGL context current on this thread
        at javax.media.opengl.glu.gl2.GLUgl2.getCurrentGL2(GLUgl2.java:195)
        at com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(Screenshot.java:259)
        at webdesktops.server.capture.ScreenCapture.main(ScreenCapture.java:82)

I read at forum that

Its actually very simple to get a screenshot of ur JOGL renderings. Here's a small snippet that could be used inside (at the end) of the display() method of ur GLEventListener:

BufferedImage tScreenshot = Screenshot.readToBufferedImage(0,0, tScreenWidth, tScreenHeight, false);
File tScreenCaptureImageFile = new File(tFileName);
ImageIO.write(tScreenshot, "png", tScreenCaptureImageFile);

... or u can press the whole process in a single line