aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-01 06:48:52 +0200
committerSven Gothel <[email protected]>2011-04-01 06:48:52 +0200
commit4b8bd5ec58cb2edfb51bd9ee930beb9c539a8a0b (patch)
tree5567f56606ea248707fe002015b90a9635250e91 /src/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java
parente8c69e69374b6650e37594ebf104602fb06b548b (diff)
Final core and demo changes for jogl merge
Core: - Region: Cleanup up constant names - Renderer: Add getRenderType() - TextRenderer: Add cache size limit - JavaFontLoader: Add FIXME 'Add cache size to limit memory usage' - UbuntuFontLoader: Add cache and FIXME 'Add cache size to limit memory usage' - TypecastFont: Add FIXME 'Add cache size to limit memory usage ??' Demos: - Relocated and split (main/listener) for jogl merge - Add 's' for screenshot - Text: - Add 'i' for live editing mode (until CR, backspace supported)
Diffstat (limited to 'src/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java')
-rw-r--r--src/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java b/src/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java
new file mode 100644
index 000000000..e0c304e49
--- /dev/null
+++ b/src/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java
@@ -0,0 +1,39 @@
+package com.jogamp.opengl.test.junit.graph.demos;
+
+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();
+ }
+
+}