Top Description Fields Constructors Methods
com.jogamp.opengl.util

public Class GLReadBufferUtil

extends Object
Class Inheritance
Known Direct Subclasses
com.jogamp.opengl.util.awt.AWTGLReadBufferUtil
Imports
java.io.File, .IOException, com.jogamp.nativewindow.util.PixelFormat, com.jogamp.opengl.GL, .GL2ES3, .GLAutoDrawable, .GLDrawable, .GLException, com.jogamp.common.nio.Buffers, com.jogamp.opengl.util.texture.Texture, .TextureData, .TextureIO, com.jogamp.opengl.util.GLPixelBuffer, .GLPixelBuffer.GLPixelAttributes, .GLPixelBuffer.GLPixelBufferProvider

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).

Field Summary

Modifier and TypeField and Description
protected boolean
protected final GLPixelBuffer.GLPixelBufferProvider
protected final GLPixelStorageModes
protected GLPixelBuffer
protected final Texture
protected TextureData

Constructor Summary

AccessConstructor and Description
public
GLReadBufferUtil(final boolean
true for RGBA readPixels, otherwise RGB readPixels.

Disclaimer

Alpha maybe forced on ES platforms!

alpha
,
final boolean
true if readPixel's TextureData shall be written to a 2d Texture
write2Texture
)

public
GLReadBufferUtil(final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider, final boolean alpha, final boolean write2Texture)

Method Summary

Modifier and TypeMethod and Description
public void
dispose(final GL gl)

public GLPixelStorageModes
public GLPixelBuffer
public GLPixelBuffer.GLPixelBufferProvider
getPixelBufferProvider()

Returns the GLPixelBufferProvider used by this instance.

public Texture

Returns:

the Texture object filled by readPixels(GLAutoDrawable, boolean), if this instance writes to a 2d Texture, otherwise null.
getTexture
()

public TextureData

Returns:

the resulting TextureData, filled by readPixels(GLAutoDrawable, boolean)
getTextureData
()

public boolean
public boolean
public boolean
readPixels(final GL
the current GL context object. It's read drawable is being used as the pixel source.
gl
,
final boolean
indicates whether to flip the data vertically or not. The context's drawable GLDrawable#isGLOriented() state is taken into account. Vertical flipping is propagated to TextureData and handled in a efficient manner there (TextureCoordinates and TextureIO writer).
mustFlipVertically
)

Read the drawable's pixels to TextureData and Texture, if requested at construction.

public boolean
readPixels(final GL
the current GL context object. It's read drawable is being used as the pixel source.
gl
,
final int
readPixel x offset
inX
,
final int
readPixel y offset
inY
,
final int
optional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width
inWidth
,
final int
optional readPixel height, used if [1 .. drawable.height], otherwise using drawable.height
inHeight
,
final boolean
indicates whether to flip the data vertically or not. The context's drawable GLDrawable#isGLOriented() state is taken into account. Vertical flipping is propagated to TextureData and handled in a efficient manner there (TextureCoordinates and TextureIO writer).
mustFlipVertically
)

Read the drawable's pixels to TextureData and Texture, if requested at construction.

protected boolean
readPixelsImpl(final GLDrawable drawable, final GL gl, final int inX, final int inY, final int width, final int height, final boolean mustFlipVertically)

public void
rewindPixelBuffer()

rewind the raw pixel ByteBuffer

public void
write(final File dest)

Write the TextureData filled by readPixels(GLAutoDrawable, boolean) to file

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hasAlphaback to summary
protected boolean hasAlpha
pixelBufferProviderback to summary
protected final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider
psmback to summary
protected final GLPixelStorageModes psm
readPixelBufferback to summary
protected GLPixelBuffer readPixelBuffer
readTextureback to summary
protected final Texture readTexture
readTextureDataback to summary
protected TextureData readTextureData

Constructor Detail

GLReadBufferUtilback to summary
public GLReadBufferUtil(final boolean alpha, final boolean write2Texture)
Parameters
alpha:boolean

true for RGBA readPixels, otherwise RGB readPixels.

Disclaimer

Alpha maybe forced on ES platforms!

write2Texture:boolean

true if readPixel's TextureData shall be written to a 2d Texture

GLReadBufferUtilback to summary
public GLReadBufferUtil(final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider, final boolean alpha, final boolean write2Texture)

Method Detail

disposeback to summary
public void dispose(final GL gl)
getGLPixelStorageModesback to summary
public GLPixelStorageModes getGLPixelStorageModes()
getPixelBufferback to summary
public GLPixelBuffer getPixelBuffer()

Returns the GLPixelBuffer, created and filled by readPixels(GLAutoDrawable, boolean).

getPixelBufferProviderback to summary
public GLPixelBuffer.GLPixelBufferProvider getPixelBufferProvider()

Returns the GLPixelBufferProvider used by this instance.

getTextureback to summary
public Texture getTexture()
Returns:Texture

the Texture object filled by readPixels(GLAutoDrawable, boolean), if this instance writes to a 2d Texture, otherwise null.

See Also
GLReadBufferUtil(boolean, boolean)
getTextureDataback to summary
public TextureData getTextureData()
Returns:TextureData

the resulting TextureData, filled by readPixels(GLAutoDrawable, boolean)

hasAlphaback to summary
public boolean hasAlpha()
isValidback to summary
public boolean isValid()
readPixelsback to summary
public boolean readPixels(final GL gl, final boolean mustFlipVertically)

Read the drawable's pixels to TextureData and Texture, if requested at construction.

Parameters
gl:GL

the current GL context object. It's read drawable is being used as the pixel source.

mustFlipVertically:boolean

indicates whether to flip the data vertically or not. The context's drawable GLDrawable#isGLOriented() state is taken into account. Vertical flipping is propagated to TextureData and handled in a efficient manner there (TextureCoordinates and TextureIO writer).

See Also
GLReadBufferUtil(boolean, boolean)
readPixelsback to summary
public boolean readPixels(final GL gl, final int inX, final int inY, final int inWidth, final int inHeight, final boolean mustFlipVertically)

Read the drawable's pixels to TextureData and Texture, if requested at construction.

Parameters
gl:GL

the current GL context object. It's read drawable is being used as the pixel source.

inX:int

readPixel x offset

inY:int

readPixel y offset

inWidth:int

optional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width

inHeight:int

optional readPixel height, used if [1 .. drawable.height], otherwise using drawable.height

mustFlipVertically:boolean

indicates whether to flip the data vertically or not. The context's drawable GLDrawable#isGLOriented() state is taken into account. Vertical flipping is propagated to TextureData and handled in a efficient manner there (TextureCoordinates and TextureIO writer).

See Also
GLReadBufferUtil(boolean, boolean)
readPixelsImplback to summary
protected boolean readPixelsImpl(final GLDrawable drawable, final GL gl, final int inX, final int inY, final int width, final int height, final boolean mustFlipVertically)
rewindPixelBufferback to summary
public void rewindPixelBuffer()

rewind the raw pixel ByteBuffer

writeback to summary
public void write(final File dest)

Write the TextureData filled by readPixels(GLAutoDrawable, boolean) to file