com.jogamp.opengl.util.awt
Class AWTGLPixelBuffer

java.lang.Object
  extended by com.jogamp.opengl.util.GLPixelBuffer
      extended by com.jogamp.opengl.util.awt.AWTGLPixelBuffer

public class AWTGLPixelBuffer
extends 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 AWTGLPixelBuffer.AWTGLPixelBufferProvider's allocate(..).

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


Nested Class Summary
static class AWTGLPixelBuffer.AWTGLPixelBufferProvider
          Provider for AWTGLPixelBuffer instances.
static class AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider
          Provider for singleton AWTGLPixelBuffer instances.
 
Nested classes/interfaces inherited from class com.jogamp.opengl.util.GLPixelBuffer
GLPixelBuffer.GLPixelAttributes, GLPixelBuffer.GLPixelBufferProvider, GLPixelBuffer.SingletonGLPixelBufferProvider
 
Field Summary
 boolean allowRowStride
          Allow GL2GL3.GL_PACK_ROW_LENGTH, or GL2ES2.GL_UNPACK_ROW_LENGTH.
static GLPixelBuffer.GLPixelAttributes awtPixelAttributesIntRGB3
           
static GLPixelBuffer.GLPixelAttributes awtPixelAttributesIntRGBA4
           
 BufferedImage image
          The underlying BufferedImage.
 
Fields inherited from class com.jogamp.opengl.util.GLPixelBuffer
buffer, bufferElemSize, byteSize, defaultProvider, depth, height, pack, pixelAttributes, width
 
Constructor Summary
AWTGLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, BufferedImage image, Buffer buffer, boolean allowRowStride)
           
 
Method Summary
 void dispose()
          Dispose resources.
 boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int minByteSize)
          Returns true, if invalid or implementation requires a new buffer based on the new size due to pixel alignment or byte size, otherwise false.
 String toString()
           
 StringBuffer toString(StringBuffer sb)
           
 
Methods inherited from class com.jogamp.opengl.util.GLPixelBuffer
clear, flip, isValid, position, position, rewind
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

awtPixelAttributesIntRGBA4

public static final GLPixelBuffer.GLPixelAttributes awtPixelAttributesIntRGBA4

awtPixelAttributesIntRGB3

public static final GLPixelBuffer.GLPixelAttributes awtPixelAttributesIntRGB3

allowRowStride

public final boolean allowRowStride
Allow GL2GL3.GL_PACK_ROW_LENGTH, or GL2ES2.GL_UNPACK_ROW_LENGTH. See requiresNewBuffer(GL, int, int, int).


image

public final BufferedImage image
The underlying BufferedImage.

Constructor Detail

AWTGLPixelBuffer

public AWTGLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes,
                        int width,
                        int height,
                        int depth,
                        boolean pack,
                        BufferedImage image,
                        Buffer buffer,
                        boolean allowRowStride)
Parameters:
pixelAttributes - the desired GLPixelBuffer.GLPixelAttributes
width - in pixels
height - in pixels
depth - in pixels
pack - true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU
image - the AWT image
buffer - the backing array
allowRowStride - If true, allow row-stride, otherwise not. See requiresNewBuffer(GL, int, int, int).
Method Detail

requiresNewBuffer

public boolean requiresNewBuffer(GL gl,
                                 int newWidth,
                                 int newHeight,
                                 int minByteSize)
Returns true, if invalid or implementation requires a new buffer based on the new size due to pixel alignment or byte size, otherwise false.

It is assumed that pixelAttributes, depth and pack stays the same!

The minimum required byte size equals to minByteSize, if > 0, otherwise utilize GLBuffers.sizeof(..) to calculate it.

If allowRowStride = false, method returns true if the new size ≠ current size.

If allowRowStride = true, see AWTGLPixelBufferProvider#AWTGLPixelBufferProvider(boolean), method returns true only if the new size > current size. Assuming user utilizes the row-stride when dealing w/ the data, i.e. GL2GL3.GL_PACK_ROW_LENGTH.

Overrides:
requiresNewBuffer in class GLPixelBuffer
Parameters:
gl - the corresponding current GL context object
newWidth - new width in pixels
newHeight - new height in pixels
minByteSize - if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore.
See Also:
GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int)

dispose

public void dispose()
Description copied from class: GLPixelBuffer
Dispose resources. See GLPixelBuffer.isValid().

Overrides:
dispose in class GLPixelBuffer

toString

public StringBuffer toString(StringBuffer sb)
Overrides:
toString in class GLPixelBuffer

toString

public String toString()
Overrides:
toString in class GLPixelBuffer


Copyright 2010 JogAmp Community.