diff options
author | Sven Gothel <[email protected]> | 2009-10-04 17:11:11 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-04 17:11:11 -0700 |
commit | 7997824464198164a74f4d20620d2f432578024c (patch) | |
tree | dd8c288d66d279f10f9edb4d35d8abeb03ccf164 /src/demos/readbuffer | |
parent | 4b9a72c24bb97ed81c79c3931d4ffb5fa53d9978 (diff) |
ReadBuffer Demos: Use NetPbmTextureWriter
Diffstat (limited to 'src/demos/readbuffer')
-rwxr-xr-x | src/demos/readbuffer/Main.java | 10 | ||||
-rwxr-xr-x | src/demos/readbuffer/ReadBuffer2File.java | 6 | ||||
-rwxr-xr-x | src/demos/readbuffer/ReadBufferBase.java | 3 | ||||
-rwxr-xr-x | src/demos/readbuffer/Surface2File.java | 6 |
4 files changed, 16 insertions, 9 deletions
diff --git a/src/demos/readbuffer/Main.java b/src/demos/readbuffer/Main.java index ccc3988..cf281b6 100755 --- a/src/demos/readbuffer/Main.java +++ b/src/demos/readbuffer/Main.java @@ -65,12 +65,13 @@ public class Main implements WindowListener, MouseListener, SurfaceUpdatedListen return windowOffscreen; } - private void run(int typeNewt, boolean fullscreen, int typeTest, GLEventListener demo) { + private void run(String glProfileStr, int typeNewt, boolean fullscreen, int typeTest, GLEventListener demo) { + GLProfile glp = GLProfile.get(glProfileStr); int width = 800; int height = 480; System.out.println("readbuffer.Main.run() Test: "+typeTest); try { - GLCapabilities caps = new GLCapabilities(null); + GLCapabilities caps = new GLCapabilities(glp); // Full init pbuffer window .. GLWindow windowOffscreen = createOffscreen(caps, width, height); @@ -146,6 +147,7 @@ public class Main implements WindowListener, MouseListener, SurfaceUpdatedListen public static int TEST_READBUFFER2SCREEN = 2; public static void main(String[] args) { + String glProfileStr = null; boolean fullscreen = false; int typeNewt = USE_NEWT ; int typeTest = TEST_SURFACE2FILE; @@ -158,6 +160,8 @@ public class Main implements WindowListener, MouseListener, SurfaceUpdatedListen } else if(args[i].equals("-test")) { i++; typeTest = str2int(args[i], typeTest); + } else if(args[i].startsWith("-GL")) { + glProfileStr = args[i].substring(1); } i++; } @@ -176,7 +180,7 @@ public class Main implements WindowListener, MouseListener, SurfaceUpdatedListen } GLEventListener demo = (GLEventListener) demoObject; - new Main().run(typeNewt, fullscreen, typeTest, demo); + new Main().run(glProfileStr, typeNewt, fullscreen, typeTest, demo); System.exit(0); } diff --git a/src/demos/readbuffer/ReadBuffer2File.java b/src/demos/readbuffer/ReadBuffer2File.java index 9b96d9b..2b30acf 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.awt.IIOTextureWriter; +import com.sun.opengl.util.texture.spi.NetPbmTextureWriter; import java.io.File; import java.io.IOException; @@ -53,14 +53,14 @@ public class ReadBuffer2File extends ReadBufferBase { super.dispose(drawable); } - IIOTextureWriter textureWriter = new IIOTextureWriter(); + NetPbmTextureWriter textureWriter = new NetPbmTextureWriter(6); int shotNum=0; void copyTextureData2File() { if(!readBufferUtil.isValid()) return; try { - textureWriter.write(new File("/tmp/shot/shot-"+shotNum+".jpg"), readBufferUtil.getTextureData()); + textureWriter.write(new File("/tmp/shot/shot-"+shotNum+"."+textureWriter.getSuffix()), readBufferUtil.getTextureData()); shotNum++; } catch (IOException ioe) { ioe.printStackTrace(); } readBufferUtil.rewindPixelBuffer(); diff --git a/src/demos/readbuffer/ReadBufferBase.java b/src/demos/readbuffer/ReadBufferBase.java index 77ffd96..04c1cdc 100755 --- a/src/demos/readbuffer/ReadBufferBase.java +++ b/src/demos/readbuffer/ReadBufferBase.java @@ -76,6 +76,9 @@ public class ReadBufferBase implements GLEventListener { if(_gl.isGL2GL3()) { _gl.getGL2GL3().glReadBuffer(GL2GL3.GL_FRONT); } + System.out.println("---------------------------"); + System.out.println(_gl.getContext()); + System.out.println("---------------------------"); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { diff --git a/src/demos/readbuffer/Surface2File.java b/src/demos/readbuffer/Surface2File.java index 12a5256..cc76f28 100755 --- a/src/demos/readbuffer/Surface2File.java +++ b/src/demos/readbuffer/Surface2File.java @@ -39,7 +39,7 @@ import javax.media.opengl.*; import com.sun.opengl.util.texture.TextureData; import com.sun.opengl.util.BufferUtil; -import com.sun.opengl.util.texture.spi.awt.IIOTextureWriter; +import com.sun.opengl.util.texture.spi.NetPbmTextureWriter; import java.io.File; import java.io.IOException; @@ -48,7 +48,7 @@ import javax.media.nativewindow.*; public class Surface2File implements SurfaceUpdatedListener { ReadBufferUtil readBufferUtil = new ReadBufferUtil(); - IIOTextureWriter textureWriter = new IIOTextureWriter(); + NetPbmTextureWriter textureWriter = new NetPbmTextureWriter(6); int shotNum=0; public void dispose() { @@ -70,7 +70,7 @@ public class Surface2File implements SurfaceUpdatedListener { if(!readBufferUtil.isValid()) return; try { - textureWriter.write(new File(basename+"-"+shotNum+".jpg"), readBufferUtil.getTextureData()); + textureWriter.write(new File(basename+"-"+shotNum+"."+textureWriter.getSuffix()), readBufferUtil.getTextureData()); shotNum++; } catch (IOException ioe) { ioe.printStackTrace(); } readBufferUtil.rewindPixelBuffer(); |