diff options
author | Rami Santina <[email protected]> | 2011-03-30 15:08:03 +0300 |
---|---|---|
committer | Rami Santina <[email protected]> | 2011-03-30 15:08:03 +0300 |
commit | 81c3642d6cd98a979808c95c27e265d0cc726ed4 (patch) | |
tree | 204741633c9169b48a9e2960318c3b948972f462 /src/demo/Screenshot.java | |
parent | fca85c495e24322dd8870832fe3934fbe2d40236 (diff) | |
parent | dbc74b98eb7429cbb51f7af0572ab53ddd0d9edc (diff) |
Merge chnages with sgothel
Diffstat (limited to 'src/demo/Screenshot.java')
-rw-r--r-- | src/demo/Screenshot.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/demo/Screenshot.java b/src/demo/Screenshot.java new file mode 100644 index 000000000..8e05b17ea --- /dev/null +++ b/src/demo/Screenshot.java @@ -0,0 +1,39 @@ +package demo; + +import java.io.File; +import java.io.IOException; + +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; + +import com.jogamp.opengl.util.texture.TextureIO; + +public class Screenshot { + + ReadBufferUtil readBufferUtil = new ReadBufferUtil(); + + public void dispose() { + readBufferUtil.dispose(); + } + + public void surface2File(GLAutoDrawable drawable, String filename) { + GL gl = drawable.getGL(); + // FIXME glFinish() is an expensive paranoia sync, should not be necessary due to spec + gl.glFinish(); + readBufferUtil.fetchOffscreenTexture(drawable, gl); + gl.glFinish(); + try { + surface2File(filename); + } catch (IOException ex) { + throw new RuntimeException("can not write survace to file", ex); + } + } + + void surface2File(String filename) throws IOException { + File file = new File(filename); + TextureIO.write(readBufferUtil.getTextureData(), file); + System.err.println("Wrote: " + file.getAbsolutePath() + ", ..."); + readBufferUtil.rewindPixelBuffer(); + } + +} |