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

public Class AWTGLPixelBuffer

extends GLPixelBuffer
Class Inheritance
Imports
java.awt.image.BufferedImage, .ColorModel, .DataBuffer, .DataBufferInt, .Raster, .SinglePixelPackedSampleModel, .WritableRaster, java.nio.Buffer, .IntBuffer, java.util.Iterator, com.jogamp.nativewindow.util.PixelFormat, com.jogamp.opengl.GL, .GLProfile, com.jogamp.common.nio.Buffers, com.jogamp.common.util.IntObjectHashMap, com.jogamp.opengl.util.GLPixelBuffer

AWT GLPixelBuffer backed by an BufferedImage of type BufferedImage#TYPE_INT_ARGB or BufferedImage#TYPE_INT_RGB.

Implementation uses an array backed IntBuffer.

AWTGLPixelBuffer can be produced via AWTGLPixelBufferProvider's allocate(..).

See AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int) for allowRowStride details.

If using allowRowStride == true, user may needs to get the aligned image since requiresNewBuffer(GL, int, int, int) will allow different width in this case.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
private final int
private static final GLPixelBuffer.GLPixelAttributes
awtPixelAttributesIntBGRA

Ignoring componentCount, since otherwise no AWT/GL matching types are found.

private static final GLPixelBuffer.GLPixelAttributes
private final PixelFormat.Composition
public final BufferedImage
image

The underlying BufferedImage.

Inherited from com.jogamp.opengl.util.GLPixelBuffer:
allowRowStridebufferbufferElemSizebyteSizedefaultProviderNoRowStridedefaultProviderWithRowStridedepthheightpackpixelAttributeswidth

Constructor Summary

AccessConstructor and Description
public
AWTGLPixelBuffer(final PixelFormat.Composition hostPixelComp, final GLPixelBuffer.GLPixelAttributes
the desired GLPixelAttributes
pixelAttributes
,
final boolean
true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.
pack
,
final int awtFormat, final int
in pixels
width
,
final int
in pixels
height
,
final int
in pixels
depth
,
final BufferedImage
the AWT image
image
,
final Buffer
the backing array
buffer
,
final boolean
If true, allow row-stride, otherwise not. See requiresNewBuffer(GL, int, int, int). If true, user shall decide whether to use a width-aligned image.
allowRowStride
)

Method Summary

Modifier and TypeMethod and Description
public void
public BufferedImage
getAlignedImage(final int width, final int height)

Returns a width- and height-aligned image representation sharing data w/ image.

public final int
public final PixelFormat.Composition
public final boolean
public StringBuilder
public String
toString()

Overrides com.jogamp.opengl.util.GLPixelBuffer.toString.

Returns a string representation of the object.
Inherited from com.jogamp.opengl.util.GLPixelBuffer:
capacityclearflipgetAllowRowStrideisValidlimitpositionpositionrequiresNewBufferrewind

Field Detail

awtFormatback to summary
private final int awtFormat
awtPixelAttributesIntBGRAback to summary
private static final GLPixelBuffer.GLPixelAttributes awtPixelAttributesIntBGRA

Ignoring componentCount, since otherwise no AWT/GL matching types are found.

Due to using RGBA and BGRA, pack/unpack usage has makes no difference.

awtPixelAttributesIntRGBAback to summary
private static final GLPixelBuffer.GLPixelAttributes awtPixelAttributesIntRGBA
hostPixelCompback to summary
private final PixelFormat.Composition hostPixelComp
imageback to summary
public final BufferedImage image

The underlying BufferedImage.

Constructor Detail

AWTGLPixelBufferback to summary
public AWTGLPixelBuffer(final PixelFormat.Composition hostPixelComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack, final int awtFormat, final int width, final int height, final int depth, final BufferedImage image, final Buffer buffer, final boolean allowRowStride)
Parameters
hostPixelComp:PixelFormat.Composition

the host PixelFormat.Composition

pixelAttributes:GLPixelBuffer.GLPixelAttributes

the desired GLPixelAttributes

pack:boolean

true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.

awtFormat:int

the used AWT format, i.e. AWTGLPixelBufferProvider#getAWTFormat(GLProfile, int)

width:int

in pixels

height:int

in pixels

depth:int

in pixels

image:BufferedImage

the AWT image

buffer:Buffer

the backing array

allowRowStride:boolean

If true, allow row-stride, otherwise not. See requiresNewBuffer(GL, int, int, int). If true, user shall decide whether to use a width-aligned image.

Method Detail

disposeback to summary
public void dispose()

Overrides com.jogamp.opengl.util.GLPixelBuffer.dispose.

Doc from com.jogamp.opengl.util.GLPixelBuffer.dispose.

Dispose resources. See isValid().

Annotations
@Override
getAlignedImageback to summary
public BufferedImage getAlignedImage(final int width, final int height) throws IllegalArgumentException

Returns a width- and height-aligned image representation sharing data w/ image.

Exceptions
IllegalArgumentException:
if requested size exceeds image size
getAWTFormatback to summary
public final int getAWTFormat()
getHostPixelCompback to summary
public final PixelFormat.Composition getHostPixelComp()
isDataBufferSourceback to summary
public final boolean isDataBufferSource(final BufferedImage imageU)
toStringback to summary
public StringBuilder toString(StringBuilder sb)

Overrides com.jogamp.opengl.util.GLPixelBuffer.toString.

Annotations
@Override
toStringback to summary
public String toString()

Overrides com.jogamp.opengl.util.GLPixelBuffer.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.opengl.util.awt back to summary

public Class AWTGLPixelBuffer.AWTGLPixelBufferProvider

extends Object
implements GLPixelBufferProvider
Class Inheritance
  • java.lang.Object
  • com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider
All Implemented Interfaces
com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider
Known Direct Subclasses
com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider

Provider for AWTGLPixelBuffer instances.

Field Summary

Modifier and TypeField and Description
private final boolean

Constructor Summary

AccessConstructor and Description
public
AWTGLPixelBufferProvider(final boolean
If true, allow row-stride, otherwise not. See getAllowRowStride() and AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int). If true, user shall decide whether to use a width-aligned image.
allowRowStride
)

Method Summary

Modifier and TypeMethod and Description
public AWTGLPixelBuffer
allocate(final GL
the corresponding current GL context object
gl
,
final PixelFormat.Composition
host pixel format, i.e. of the source or sink depending on pack, e.g. fetched via getHostPixelComp(GLProfile, int). If null, pixelAttributes instance maybe used or an exception is thrown, depending on implementation semantics.
hostPixComp
,
final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean
true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.
pack
,
final int
in pixels
width
,
final int
in pixels
height
,
final int
in pixels
depth
,
final int
if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore.
minByteSize
)

Implements com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

Allocates a new GLPixelBuffer object.
public boolean
public GLPixelBuffer.GLPixelAttributes
getAttributes(final GL
the corresponding current GL context object
gl
,
final int
RGBA component count, i.e. 1 (luminance, alpha or red), 3 (RGB) or 4 (RGBA)
componentCount
,
final boolean
true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.
pack
)

Implements com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getAttributes.

Returns RGB[A] GLPixelAttributes matching GL, componentCount and pack.
public GLPixelBuffer.GLPixelAttributes
getAttributes(final GLProfile glp, final int componentCount)

public int
getAWTFormat(final GLProfile glp, final int componentCount)

Returns one of

public PixelFormat
getAWTPixelFormat(final GLProfile glp, final int componentCount)

public PixelFormat.Composition
getHostPixelComp(final GLProfile
the corresponding current GL context object
glp
,
final int
RGBA component count, i.e. 1 (luminance, alpha or red), 3 (RGB) or 4 (RGBA)
componentCount
)

Implements com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getHostPixelComp.

Returns the host PixelFormat.Composition matching GL and componentCount if required by implementation, otherwise null.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowRowStrideback to summary
private final boolean allowRowStride

Constructor Detail

AWTGLPixelBufferProviderback to summary
public AWTGLPixelBufferProvider(final boolean allowRowStride)
Parameters
allowRowStride:boolean

If true, allow row-stride, otherwise not. See getAllowRowStride() and AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int). If true, user shall decide whether to use a width-aligned image.

Method Detail

allocateback to summary
public AWTGLPixelBuffer allocate(final GL gl, final PixelFormat.Composition hostPixComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack, final int width, final int height, final int depth, final int minByteSize)

Implements com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

Allocates a new GLPixelBuffer object.

The minimum required remaining byte size equals to minByteSize, if > 0, otherwise utilize GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean) to calculate it.

Returns an array backed IntBuffer of size

width*height*SIZEOF_INT.

Parameters
gl:GL

the corresponding current GL context object

hostPixComp:PixelFormat.Composition

host pixel format, i.e. of the source or sink depending on pack, e.g. fetched via getHostPixelComp(GLProfile, int). If null, pixelAttributes instance maybe used or an exception is thrown, depending on implementation semantics.

pixelAttributes:GLPixelBuffer.GLPixelAttributes

the desired GLPixelAttributes, e.g. fetched via getAttributes(GL, int, boolean)

pack:boolean

true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.

width:int

in pixels

height:int

in pixels

depth:int

in pixels

minByteSize:int

if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore.

Annotations
@Override
getAllowRowStrideback to summary
public boolean getAllowRowStride()

Implements com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getAllowRowStride.

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getAllowRowStride.

Allow GL2ES3#GL_PACK_ROW_LENGTH, or GL2ES2#GL_UNPACK_ROW_LENGTH.

Annotations
@Override
getAttributesback to summary
public GLPixelBuffer.GLPixelAttributes getAttributes(final GL gl, final int componentCount, final boolean pack)

Implements com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getAttributes.

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getAttributes.

Returns RGB[A] GLPixelAttributes matching GL, componentCount and pack.

Parameters
gl:GL

the corresponding current GL context object

componentCount:int

RGBA component count, i.e. 1 (luminance, alpha or red), 3 (RGB) or 4 (RGBA)

pack:boolean

true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.

Annotations
@Override
getAttributesback to summary
public GLPixelBuffer.GLPixelAttributes getAttributes(final GLProfile glp, final int componentCount)
getAWTFormatback to summary
public int getAWTFormat(final GLProfile glp, final int componentCount)

Returns one of

getAWTPixelFormatback to summary
public PixelFormat getAWTPixelFormat(final GLProfile glp, final int componentCount)
getHostPixelCompback to summary
public PixelFormat.Composition getHostPixelComp(final GLProfile glp, final int componentCount)

Implements com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getHostPixelComp.

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.getHostPixelComp.

Returns the host PixelFormat.Composition matching GL and componentCount if required by implementation, otherwise null.

Returns a valid PixelFormat.Composition instance from getAWTPixelFormat(GLProfile, int).

Parameters
glp:GLProfile

the corresponding current GL context object

componentCount:int

RGBA component count, i.e. 1 (luminance, alpha or red), 3 (RGB) or 4 (RGBA)

Annotations
@Override
com.jogamp.opengl.util.awt back to summary

public Class AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider

extends AWTGLPixelBufferProvider
implements SingletonGLPixelBufferProvider
Class Inheritance
All Implemented Interfaces
com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider, com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider

Provider for singleton AWTGLPixelBuffer instances.

Provider instance holds the last AWTGLPixelBuffer instance allocated. A new allocation will return same instance, if a new buffer is not required. The latter is true if size are compatible, hence allowRowStride should be enabled, if possible.

Field Summary

Modifier and TypeField and Description
private final IntObjectHashMap

Constructor Summary

AccessConstructor and Description
public
SingleAWTGLPixelBufferProvider(final boolean
If true, allow row-stride, otherwise not. See AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int).
allowRowStride
)

Method Summary

Modifier and TypeMethod and Description
public AWTGLPixelBuffer
allocate(final GL
the corresponding current GL context object
gl
,
PixelFormat.Composition
host pixel format, i.e. of the source or sink depending on pack, e.g. fetched via getHostPixelComp(GLProfile, int). If null, pixelAttributes instance maybe used or an exception is thrown, depending on implementation semantics.
hostPixComp
,
final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean
true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.
pack
,
final int
in pixels
width
,
final int
in pixels
height
,
final int
in pixels
depth
,
final int
if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore.
minByteSize
)

Overrides com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider.allocate.

Implements com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.allocate, com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

Allocates a new GLPixelBuffer object.
private AWTGLPixelBuffer
allocateImpl(final PixelFormat.Composition hostPixComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack, final int awtFormat, final int width, final int height, final int depth, final int minByteSize)

public void
private static int
getHashCode(final PixelFormat.Composition hostPixelComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack)

public AWTGLPixelBuffer
getSingleBuffer(final PixelFormat.Composition
host pixel format, i.e. of the source or sink depending on pack, e.g. fetched via getHostPixelComp(GLProfile, int). If null, pixelAttributes instance maybe used or an exception is thrown, depending on implementation semantics.
hostPixelComp
,
final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean
true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.
pack
)

Implements com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.getSingleBuffer.

Return the last allocated AWTGLPixelBuffer, if compatible w/ the given PixelFormat.Composition and GLPixelAttributes.
public AWTGLPixelBuffer

Returns:

the newly initialized single AWTGLPixelBuffer, or null if already allocated.
initSingleton
(final GLProfile glp, final int
RGBA component count, i.e. 1 (luminance, alpha or red), 3 (RGB) or 4 (RGBA)
componentCount
,
final boolean
true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.
pack
,
final int width, final int height, final int depth)

Implements com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.initSingleton.

Initializes the single AWTGLPixelBuffer w/ a given size, if not yet allocated.
Inherited from com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider:
getAllowRowStridegetAttributesgetAttributesgetAWTFormatgetAWTPixelFormatgetHostPixelComp

Field Detail

bufferMapback to summary
private final IntObjectHashMap bufferMap

Constructor Detail

SingleAWTGLPixelBufferProviderback to summary
public SingleAWTGLPixelBufferProvider(final boolean allowRowStride)
Parameters
allowRowStride:boolean

If true, allow row-stride, otherwise not. See AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int).

Method Detail

allocateback to summary
public AWTGLPixelBuffer allocate(final GL gl, PixelFormat.Composition hostPixComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack, final int width, final int height, final int depth, final int minByteSize)

Overrides com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider.allocate.

Implements com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.allocate, com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

Doc from com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.allocate.

Allocates a new GLPixelBuffer object.

The minimum required remaining byte size equals to minByteSize, if > 0, otherwise utilize GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean) to calculate it.

Being called to gather the initial GLPixelBuffer, or a new replacement GLPixelBuffer if GLPixelBuffer#requiresNewBuffer(GL, int, int, int).

Returns an array backed IntBuffer of size

width*height*SIZEOF_INT.

Parameters
gl:GL

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

the corresponding current GL context object

hostPixComp:PixelFormat.Composition

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

host pixel format, i.e. of the source or sink depending on pack, e.g. fetched via getHostPixelComp(GLProfile, int). If null, pixelAttributes instance maybe used or an exception is thrown, depending on implementation semantics.

pixelAttributes:GLPixelBuffer.GLPixelAttributes

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

the desired GLPixelAttributes, e.g. fetched via getAttributes(GL, int, boolean)

pack:boolean

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.

width:int

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

in pixels

height:int

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

in pixels

depth:int

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

in pixels

minByteSize:int

Doc from com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider.allocate.

if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore.

Annotations
@Override
allocateImplback to summary
private AWTGLPixelBuffer allocateImpl(final PixelFormat.Composition hostPixComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack, final int awtFormat, final int width, final int height, final int depth, final int minByteSize)
disposeback to summary
public void dispose()

Implements com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.dispose.

Doc from com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.dispose.

Dispose all resources.

Annotations
@Override
getHashCodeback to summary
private static int getHashCode(final PixelFormat.Composition hostPixelComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack)
getSingleBufferback to summary
public AWTGLPixelBuffer getSingleBuffer(final PixelFormat.Composition hostPixelComp, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean pack)

Implements com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.getSingleBuffer.

Return the last allocated AWTGLPixelBuffer, if compatible w/ the given PixelFormat.Composition and GLPixelAttributes.

Parameters
hostPixelComp:PixelFormat.Composition

Doc from com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.getSingleBuffer.

host pixel format, i.e. of the source or sink depending on pack, e.g. fetched via getHostPixelComp(GLProfile, int). If null, pixelAttributes instance maybe used or an exception is thrown, depending on implementation semantics.

pixelAttributes:GLPixelBuffer.GLPixelAttributes

Doc from com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.getSingleBuffer.

the desired GLPixelAttributes, e.g. fetched via getAttributes(GL, int, boolean)

pack:boolean

Doc from com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.getSingleBuffer.

true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.

Annotations
@Override
initSingletonback to summary
public AWTGLPixelBuffer initSingleton(final GLProfile glp, final int componentCount, final boolean pack, final int width, final int height, final int depth)

Implements com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.initSingleton.

Initializes the single AWTGLPixelBuffer w/ a given size, if not yet allocated.

Parameters
componentCount:int

Doc from com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.initSingleton.

RGBA component count, i.e. 1 (luminance, alpha or red), 3 (RGB) or 4 (RGBA)

pack:boolean

Doc from com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider.initSingleton.

true for read mode GPU -> CPU, e.g. glReadPixels. false for write mode CPU -> GPU, e.g. glTexImage2D.

Returns:AWTGLPixelBuffer

the newly initialized single AWTGLPixelBuffer, or null if already allocated.

Annotations
@Override