com.jogamp.opengl.util
Class GLReadBufferUtil

java.lang.Object
  extended by com.jogamp.opengl.util.GLReadBufferUtil

public class GLReadBufferUtil
extends Object

Utility to read out the current FB to TextureData, optionally writing the data back to a texture object.

May be used directly to write the TextureData to file (screenshot).


Constructor Summary
GLReadBufferUtil(boolean alpha, boolean write2Texture)
           
 
Method Summary
 void dispose(GL gl)
           
 ByteBuffer getPixelBuffer()
           
 Texture getTexture()
           
 TextureData getTextureData()
           
 boolean isValid()
           
 void readPixels(GL gl, GLDrawable drawable, boolean flip)
          Read the drawable's pixels to TextureData and Texture, if requested at construction
 void rewindPixelBuffer()
          rewind the raw pixel ByteBuffer
 void write(File dest)
          Write the TextureData filled by #readPixels(GLAutoDrawable, boolean) to file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLReadBufferUtil

public GLReadBufferUtil(boolean alpha,
                        boolean write2Texture)
Parameters:
alpha - true for RGBA readPixels, otherwise RGB readPixels
write2Texture - true if readPixel's TextureData shall be written to a 2d Texture
Method Detail

isValid

public boolean isValid()

getPixelBuffer

public ByteBuffer getPixelBuffer()
Returns:
the raw pixel ByteBuffer, filled by #readPixels(GLAutoDrawable, boolean)

rewindPixelBuffer

public void rewindPixelBuffer()
rewind the raw pixel ByteBuffer


getTextureData

public TextureData getTextureData()
Returns:
the resulting TextureData, filled by #readPixels(GLAutoDrawable, boolean)

getTexture

public Texture getTexture()
Returns:
the Texture object filled by #readPixels(GLAutoDrawable, boolean), if this instance writes to a 2d Texture, otherwise null.
See Also:
GLReadBufferUtil(boolean, boolean)

write

public void write(File dest)
Write the TextureData filled by #readPixels(GLAutoDrawable, boolean) to file


readPixels

public void readPixels(GL gl,
                       GLDrawable drawable,
                       boolean flip)
Read the drawable's pixels to TextureData and Texture, if requested at construction

Parameters:
gl - the current GL object
drawable - the drawable to read from
flip - weather to flip the data vertically or not
See Also:
GLReadBufferUtil(boolean, boolean)

dispose

public void dispose(GL gl)


Copyright 2010 JogAmp Community.