JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.opengl.util.GLReadBufferUtil Class Reference

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

Inheritance diagram for com.jogamp.opengl.util.GLReadBufferUtil:
Collaboration diagram for com.jogamp.opengl.util.GLReadBufferUtil:

Public Member Functions

 GLReadBufferUtil (final boolean requestAlpha, final boolean write2Texture)
 Using the default GLPixelBuffer: GLPixelBuffer#defaultProviderNoRowStride. More...
 
 GLReadBufferUtil (final GLPixelBufferProvider pixelBufferProvider, final boolean requestAlpha, final boolean write2Texture)
 
void setReadBuffer (final int name)
 
GLPixelBufferProvider getPixelBufferProvider ()
 Returns the GLPixelBufferProvider used by this instance. More...
 
boolean isValid ()
 
boolean hasAlpha ()
 Returns true if the OpenGL read data contains alpha. More...
 
GLPixelStorageModes getGLPixelStorageModes ()
 
GLPixelBuffer getPixelBuffer ()
 Returns the GLPixelBuffer, created and filled by readPixels(GLAutoDrawable, boolean). More...
 
void rewindPixelBuffer ()
 rewind the raw pixel ByteBuffer More...
 
TextureData getTextureData ()
 
Texture getTexture ()
 
void write (final File dest)
 Write the TextureData filled by readPixels(GLAutoDrawable, boolean) to file. More...
 
boolean readPixels (final GL gl, final boolean mustFlipVertically)
 Read the drawable's pixels to TextureData and Texture, if requested at construction. More...
 
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. More...
 
void dispose (final GL gl)
 

Protected Member Functions

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

Protected Attributes

final GLPixelBufferProvider pixelBufferProvider
 
final Texture readTexture
 
final GLPixelStorageModes psm
 
final boolean alphaRequested
 
boolean hasAlpha
 
GLPixelBuffer readPixelBuffer = null
 
TextureData readTextureData = null
 
int readBuffer = -1
 

Detailed Description

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

Definition at line 53 of file GLReadBufferUtil.java.

Constructor & Destructor Documentation

◆ GLReadBufferUtil() [1/2]

com.jogamp.opengl.util.GLReadBufferUtil.GLReadBufferUtil ( final boolean  requestAlpha,
final boolean  write2Texture 
)

Using the default GLPixelBuffer: GLPixelBuffer#defaultProviderNoRowStride.

Parameters
requestAlphatrue for RGBA readPixels, otherwise RGB readPixels. Disclaimer: hasAlpha()==true maybe forced depending on the used GLPixelBufferProvider, i.e. on ES platforms, when calling readPixels.
write2Texturetrue if readPixel's TextureData shall be written to a 2d Texture

Definition at line 70 of file GLReadBufferUtil.java.

◆ GLReadBufferUtil() [2/2]

com.jogamp.opengl.util.GLReadBufferUtil.GLReadBufferUtil ( final GLPixelBufferProvider  pixelBufferProvider,
final boolean  requestAlpha,
final boolean  write2Texture 
)
Parameters
pixelBufferProvidercustom GLPixelBuffer
requestAlphatrue for RGBA readPixels, otherwise RGB readPixels. Disclaimer: hasAlpha()==true maybe forced depending on the used GLPixelBufferProvider, i.e. on ES platforms, when calling readPixels.
write2Texturetrue if readPixel's TextureData shall be written to a 2d Texture

Definition at line 79 of file GLReadBufferUtil.java.

Member Function Documentation

◆ dispose()

void com.jogamp.opengl.util.GLReadBufferUtil.dispose ( final GL  gl)

Definition at line 281 of file GLReadBufferUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGLPixelStorageModes()

GLPixelStorageModes com.jogamp.opengl.util.GLReadBufferUtil.getGLPixelStorageModes ( )

Definition at line 99 of file GLReadBufferUtil.java.

◆ getPixelBuffer()

GLPixelBuffer com.jogamp.opengl.util.GLReadBufferUtil.getPixelBuffer ( )

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

Definition at line 104 of file GLReadBufferUtil.java.

Here is the caller graph for this function:

◆ getPixelBufferProvider()

GLPixelBufferProvider com.jogamp.opengl.util.GLReadBufferUtil.getPixelBufferProvider ( )

Returns the GLPixelBufferProvider used by this instance.

Definition at line 90 of file GLReadBufferUtil.java.

◆ getTexture()

Texture com.jogamp.opengl.util.GLReadBufferUtil.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)

Definition at line 121 of file GLReadBufferUtil.java.

◆ getTextureData()

TextureData com.jogamp.opengl.util.GLReadBufferUtil.getTextureData ( )
Returns
the resulting TextureData, filled by readPixels(GLAutoDrawable, boolean)

Definition at line 114 of file GLReadBufferUtil.java.

Here is the caller graph for this function:

◆ hasAlpha()

boolean com.jogamp.opengl.util.GLReadBufferUtil.hasAlpha ( )

Returns true if the OpenGL read data contains alpha.

This value is lazily determined after the first call of readPixels

Definition at line 97 of file GLReadBufferUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

boolean com.jogamp.opengl.util.GLReadBufferUtil.isValid ( )

Definition at line 92 of file GLReadBufferUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readPixels() [1/2]

boolean com.jogamp.opengl.util.GLReadBufferUtil.readPixels ( final GL  gl,
final boolean  mustFlipVertically 
)

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

Parameters
glthe current GL context object. It's read drawable is being used as the pixel source.
mustFlipVerticallyindicates 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)

Definition at line 147 of file GLReadBufferUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readPixels() [2/2]

boolean com.jogamp.opengl.util.GLReadBufferUtil.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
glthe current GL context object. It's read drawable is being used as the pixel source.
inXreadPixel x offset
inYreadPixel y offset
inWidthoptional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width
inHeightoptional readPixel height, used if [1 .. drawable.height], otherwise using drawable.height
mustFlipVerticallyindicates 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)

Definition at line 166 of file GLReadBufferUtil.java.

Here is the call graph for this function:

◆ readPixelsImpl()

boolean com.jogamp.opengl.util.GLReadBufferUtil.readPixelsImpl ( final GLDrawable  drawable,
final GL  gl,
final int  inX,
final int  inY,
final int  width,
final int  height,
final boolean  mustFlipVertically 
)
protected

Definition at line 182 of file GLReadBufferUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rewindPixelBuffer()

void com.jogamp.opengl.util.GLReadBufferUtil.rewindPixelBuffer ( )

rewind the raw pixel ByteBuffer

Definition at line 109 of file GLReadBufferUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setReadBuffer()

void com.jogamp.opengl.util.GLReadBufferUtil.setReadBuffer ( final int  name)

Definition at line 87 of file GLReadBufferUtil.java.

◆ write()

void com.jogamp.opengl.util.GLReadBufferUtil.write ( final File  dest)

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

Definition at line 126 of file GLReadBufferUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ alphaRequested

final boolean com.jogamp.opengl.util.GLReadBufferUtil.alphaRequested
protected

Definition at line 57 of file GLReadBufferUtil.java.

◆ hasAlpha

boolean com.jogamp.opengl.util.GLReadBufferUtil.hasAlpha
protected

Definition at line 59 of file GLReadBufferUtil.java.

◆ pixelBufferProvider

final GLPixelBufferProvider com.jogamp.opengl.util.GLReadBufferUtil.pixelBufferProvider
protected

Definition at line 54 of file GLReadBufferUtil.java.

◆ psm

final GLPixelStorageModes com.jogamp.opengl.util.GLReadBufferUtil.psm
protected

Definition at line 56 of file GLReadBufferUtil.java.

◆ readBuffer

int com.jogamp.opengl.util.GLReadBufferUtil.readBuffer = -1
protected

Definition at line 62 of file GLReadBufferUtil.java.

◆ readPixelBuffer

GLPixelBuffer com.jogamp.opengl.util.GLReadBufferUtil.readPixelBuffer = null
protected

Definition at line 60 of file GLReadBufferUtil.java.

◆ readTexture

final Texture com.jogamp.opengl.util.GLReadBufferUtil.readTexture
protected

Definition at line 55 of file GLReadBufferUtil.java.

◆ readTextureData

TextureData com.jogamp.opengl.util.GLReadBufferUtil.readTextureData = null
protected

Definition at line 61 of file GLReadBufferUtil.java.


The documentation for this class was generated from the following file: