com.jogamp.opengl.util
Class GLPixelBuffer

java.lang.Object
  extended by com.jogamp.opengl.util.GLPixelBuffer
Direct Known Subclasses:
AWTGLPixelBuffer

public class GLPixelBuffer
extends Object

OpenGL pixel data buffer, allowing user to provide buffers via their GLPixelBuffer.GLPixelBufferProvider implementation.

GLPixelBuffer.GLPixelBufferProvider produces a GLPixelBuffer.

You may use defaultProvider.


Nested Class Summary
static class GLPixelBuffer.GLPixelAttributes
          Pixel attributes.
static interface GLPixelBuffer.GLPixelBufferProvider
          Allows user to interface with another toolkit to define GLPixelBuffer.GLPixelAttributes and memory buffer to produce TextureData.
static interface GLPixelBuffer.SingletonGLPixelBufferProvider
          Single GLPixelBuffer provider.
 
Field Summary
 Buffer buffer
          Buffer holding the pixel data.
 int bufferElemSize
          Buffer element size in bytes.
 int byteSize
          Byte size of the buffer.
static GLPixelBuffer.GLPixelBufferProvider defaultProvider
          Default GLPixelBuffer.GLPixelBufferProvider utilizing best match for GLPixelBuffer.GLPixelAttributes and allocating a ByteBuffer.
 int depth
          Depth in pixels.
 int height
          Height in pixels.
 boolean pack
          Data packing direction.
 GLPixelBuffer.GLPixelAttributes pixelAttributes
          The GLPixelBuffer.GLPixelAttributes.
 int width
          Width in pixels.
 
Constructor Summary
GLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, Buffer buffer)
           
 
Method Summary
 Buffer clear()
           
 void dispose()
          Dispose resources.
 Buffer flip()
           
 boolean isValid()
          Is not disposed and has byteSize > 0.
 int position()
          Returns the byte position of the buffer.
 Buffer position(int bytePos)
          Sets the byte position of the buffer.
 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.
 Buffer rewind()
           
 String toString()
           
 StringBuffer toString(StringBuffer sb)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultProvider

public static GLPixelBuffer.GLPixelBufferProvider defaultProvider
Default GLPixelBuffer.GLPixelBufferProvider utilizing best match for GLPixelBuffer.GLPixelAttributes and allocating a ByteBuffer.


pixelAttributes

public final GLPixelBuffer.GLPixelAttributes pixelAttributes
The GLPixelBuffer.GLPixelAttributes.


width

public final int width
Width in pixels.


height

public final int height
Height in pixels.


depth

public final int depth
Depth in pixels.


pack

public final boolean pack
Data packing direction. If true for read mode GPU -> CPU, false for write mode CPU -> GPU.


byteSize

public final int byteSize
Byte size of the buffer. Actually the number of Buffer.remaining() bytes when passed in ctor.


buffer

public final Buffer buffer
Buffer holding the pixel data. If rewind(), it holds byteSize Buffer.remaining() bytes.

By default the Buffer is a ByteBuffer, due to DefProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int). However, other GLPixelBuffer.GLPixelBufferProvider may utilize different Buffer types.


bufferElemSize

public final int bufferElemSize
Buffer element size in bytes.

Constructor Detail

GLPixelBuffer

public GLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes,
                     int width,
                     int height,
                     int depth,
                     boolean pack,
                     Buffer buffer)
Method Detail

toString

public StringBuffer toString(StringBuffer sb)

toString

public String toString()
Overrides:
toString in class Object

isValid

public boolean isValid()
Is not disposed and has byteSize > 0.


rewind

public Buffer rewind()

position

public int position()
Returns the byte position of the buffer.


position

public Buffer position(int bytePos)
Sets the byte position of the buffer.


flip

public Buffer flip()

clear

public Buffer clear()

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.

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()
Dispose resources. See isValid().



Copyright 2010 JogAmp Community.