Login  Register

Re: Make screenshot of work display.

Posted by Sven Gothel on Sep 11, 2012; 3:10pm
URL: https://forum.jogamp.org/Make-screenshot-of-work-display-tp4026085p4026100.html

On 09/11/2012 04:31 PM, gouessej [via jogamp] wrote:
> Yes you must call readToBufferedImage only when the OpenGL context is current,
> for example in GLEventListener.display(), you cannot call it directly in your
> main method, you have to create a canvas, set a GLEventListener to it, use an
> animator and it will work fine.

I recommend using GLReadBufferUtil as demonstrated in UITest's snapshot(..):
        gl.glFinish(); // just make sure rendering finished ..
        if(readBufferUtil.readPixels(gl, false)) {
            readBufferUtil.write(new File("snap.png"));
        }                

It benefits of being toolkit independent and works well w/ ES1, ES2
and desktop GL profiles.

UITest is our JUnit test super-class.

~Sven




signature.asc (907 bytes) Download Attachment