summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/demos/es1/RedSquare.java4
-rwxr-xr-xsrc/demos/readbuffer/ReadBuffer2File.java9
-rwxr-xr-xsrc/demos/readbuffer/Surface2File.java11
3 files changed, 16 insertions, 8 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index 5018d5b..026e1c2 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -138,7 +138,9 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
glAnimator = new Animator(Thread.currentThread().getThreadGroup(), window);
glAnimator.start();
while (glAnimator.isAnimating()) {
- Thread.yield();
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {}
}
shutdown();
} else {
diff --git a/src/demos/readbuffer/ReadBuffer2File.java b/src/demos/readbuffer/ReadBuffer2File.java
index 2b30acf..ef908c4 100755
--- a/src/demos/readbuffer/ReadBuffer2File.java
+++ b/src/demos/readbuffer/ReadBuffer2File.java
@@ -37,7 +37,7 @@ import java.nio.*;
import javax.media.opengl.*;
import com.sun.opengl.util.texture.TextureData;
-import com.sun.opengl.util.texture.spi.NetPbmTextureWriter;
+import com.sun.opengl.util.texture.TextureIO;
import java.io.File;
import java.io.IOException;
@@ -53,14 +53,17 @@ public class ReadBuffer2File extends ReadBufferBase {
super.dispose(drawable);
}
- NetPbmTextureWriter textureWriter = new NetPbmTextureWriter(6);
int shotNum=0;
void copyTextureData2File() {
if(!readBufferUtil.isValid()) return;
try {
- textureWriter.write(new File("/tmp/shot/shot-"+shotNum+"."+textureWriter.getSuffix()), readBufferUtil.getTextureData());
+ File file = File.createTempFile("shot"+shotNum+"-", ".ppm");
+ TextureIO.write(readBufferUtil.getTextureData(), file);
+ if(0==shotNum) {
+ System.out.println("Wrote: "+file.getAbsolutePath()+", ...");
+ }
shotNum++;
} catch (IOException ioe) { ioe.printStackTrace(); }
readBufferUtil.rewindPixelBuffer();
diff --git a/src/demos/readbuffer/Surface2File.java b/src/demos/readbuffer/Surface2File.java
index cc76f28..f03918c 100755
--- a/src/demos/readbuffer/Surface2File.java
+++ b/src/demos/readbuffer/Surface2File.java
@@ -37,9 +37,9 @@ import java.nio.*;
import javax.media.opengl.*;
import com.sun.opengl.util.texture.TextureData;
+import com.sun.opengl.util.texture.TextureIO;
import com.sun.opengl.util.BufferUtil;
-import com.sun.opengl.util.texture.spi.NetPbmTextureWriter;
import java.io.File;
import java.io.IOException;
@@ -48,7 +48,6 @@ import javax.media.nativewindow.*;
public class Surface2File implements SurfaceUpdatedListener {
ReadBufferUtil readBufferUtil = new ReadBufferUtil();
- NetPbmTextureWriter textureWriter = new NetPbmTextureWriter(6);
int shotNum=0;
public void dispose() {
@@ -61,7 +60,7 @@ public class Surface2File implements SurfaceUpdatedListener {
GLContext ctx = GLContext.getCurrent();
if(null!=ctx && ctx.getGLDrawable()==drawable) {
readBufferUtil.fetchOffscreenTexture(drawable, ctx.getGL());
- surface2File("/tmp/shot/shot");
+ surface2File("shot");
}
}
}
@@ -70,7 +69,11 @@ public class Surface2File implements SurfaceUpdatedListener {
if(!readBufferUtil.isValid()) return;
try {
- textureWriter.write(new File(basename+"-"+shotNum+"."+textureWriter.getSuffix()), readBufferUtil.getTextureData());
+ File file = File.createTempFile(basename+shotNum+"-", ".ppm");
+ TextureIO.write(readBufferUtil.getTextureData(), file);
+ if(0==shotNum) {
+ System.out.println("Wrote: "+file.getAbsolutePath()+", ...");
+ }
shotNum++;
} catch (IOException ioe) { ioe.printStackTrace(); }
readBufferUtil.rewindPixelBuffer();