Class GLPixelBuffer
- java.lang.Object
-
- com.jogamp.opengl.util.GLPixelBuffer
-
- Direct Known Subclasses:
AWTGLPixelBuffer
public class GLPixelBuffer extends Object
OpenGL pixel data buffer, allowing user to provide buffers via theirGLPixelBuffer.GLPixelBufferProvider
implementation.GLPixelBuffer.GLPixelBufferProvider
produces aGLPixelBuffer
.You may use
defaultProviderNoRowStride
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GLPixelBuffer.DefaultGLPixelBufferProvider
static class
GLPixelBuffer.GLPixelAttributes
Pixel attributes.static interface
GLPixelBuffer.GLPixelBufferProvider
Allows user to interface with another toolkit to defineGLPixelBuffer.GLPixelAttributes
and memory buffer to produceTextureData
.static interface
GLPixelBuffer.SingletonGLPixelBufferProvider
SingleGLPixelBuffer
provider.
-
Field Summary
Fields Modifier and Type Field Description boolean
allowRowStride
Buffer
buffer
Buffer holding the pixel data.int
bufferElemSize
Buffer element size in bytes.int
byteSize
Byte size of the buffer.static GLPixelBuffer.GLPixelBufferProvider
defaultProviderNoRowStride
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==false
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
.static GLPixelBuffer.GLPixelBufferProvider
defaultProviderWithRowStride
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==true
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
.int
depth
Depth in pixels.int
height
boolean
pack
Data packing direction.GLPixelBuffer.GLPixelAttributes
pixelAttributes
int
width
-
Constructor Summary
Constructors Constructor Description GLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes, boolean pack, int width, int height, int depth, Buffer buffer, boolean allowRowStride)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
capacity()
Returns the byte capacity of thebuffer
.Buffer
clear()
SeeBuffer.clear()
.void
dispose()
Dispose resources.Buffer
flip()
SeeBuffer.flip()
.boolean
getAllowRowStride()
boolean
isValid()
int
limit()
Returns the byte limit of thebuffer
.int
position()
Returns the byte position of thebuffer
.Buffer
position(int bytePos)
Sets the byte position of thebuffer
.boolean
requiresNewBuffer(GL gl, int newWidth, int newHeight, int newByteSize)
Returns true, ifinvalid
or implementation requires a new buffer based on the new size due to pixel alignment or byte size, otherwise false.Buffer
rewind()
SeeBuffer.rewind()
.String
toString()
StringBuilder
toString(StringBuilder sb)
-
-
-
Field Detail
-
defaultProviderNoRowStride
public static final GLPixelBuffer.GLPixelBufferProvider defaultProviderNoRowStride
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==false
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
.
-
defaultProviderWithRowStride
public static final GLPixelBuffer.GLPixelBufferProvider defaultProviderWithRowStride
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==true
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
.
-
pixelAttributes
public final GLPixelBuffer.GLPixelAttributes pixelAttributes
-
width
public final int width
Width in pixels, representingbuffer
'sbyteSize
.May not represent actual image width as user may re-use buffer for different dimensions, see
requiresNewBuffer(GL, int, int, int)
.
-
height
public final int height
Height in pixels, representingbuffer
'sbyteSize
.May not represent actual image height as user may re-use buffer for different dimensions, see
requiresNewBuffer(GL, int, int, int)
.
-
depth
public final int depth
Depth in pixels.
-
pack
public final boolean pack
Data packing direction.true
for read mode GPU -> CPU, e.g.glReadPixels
.false
for write mode CPU -> GPU, e.g.glTexImage2D
.
-
byteSize
public final int byteSize
Byte size of the buffer. Actually the number ofBuffer.remaining()
bytes when passed in ctor.
-
buffer
public final Buffer buffer
Buffer holding the pixel data. Ifrewind()
, it holdsbyteSize
Buffer.remaining()
bytes.By default the
Buffer
is aByteBuffer
, due toDefProvider#allocate(GL, PixelFormat.Composition, GLPixelAttributes, boolean, int, int, int, int)
. However, otherGLPixelBuffer.GLPixelBufferProvider
may utilize differentBuffer
types.
-
bufferElemSize
public final int bufferElemSize
Buffer element size in bytes.
-
allowRowStride
public final boolean allowRowStride
-
-
Constructor Detail
-
GLPixelBuffer
public GLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes, boolean pack, int width, int height, int depth, Buffer buffer, boolean allowRowStride)
- Parameters:
pixelAttributes
- the desiredGLPixelBuffer.GLPixelAttributes
pack
-true
for read mode GPU -> CPU, e.g.glReadPixels
.false
for write mode CPU -> GPU, e.g.glTexImage2D
.width
- in pixelsheight
- in pixelsdepth
- in pixelsbuffer
- the backing arrayallowRowStride
- Iftrue
, allow row-stride, otherwise not. SeerequiresNewBuffer(GL, int, int, int)
.hostPixelComp
- the hostPixelFormat.Composition
-
-
Method Detail
-
toString
public StringBuilder toString(StringBuilder sb)
-
getAllowRowStride
public final boolean getAllowRowStride()
-
isValid
public boolean isValid()
-
rewind
public Buffer rewind()
SeeBuffer.rewind()
.
-
position
public int position()
Returns the byte position of thebuffer
.
-
capacity
public int capacity()
Returns the byte capacity of thebuffer
.
-
limit
public int limit()
Returns the byte limit of thebuffer
.
-
flip
public Buffer flip()
SeeBuffer.flip()
.
-
clear
public Buffer clear()
SeeBuffer.clear()
.
-
requiresNewBuffer
public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int newByteSize)
Returns true, ifinvalid
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
andpack
stays the same!The minimum required byte size equals to
minByteSize
, if > 0, otherwiseGLBuffers.sizeof(..)
is being used to calculate it. This value is referred to newByteSize.If
, method returnsallowRowStride
= falsetrue
if the newByteSize > currentByteSize or thenewWidth
!=currentWidth
.If
, seeallowRowStride
= trueGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
, method returnstrue
only if the newByteSize > currentByteSize. Assuming user utilizes the row-stride when dealing w/ the data, i.e.GL2ES3.GL_PACK_ROW_LENGTH
.- Parameters:
gl
- the corresponding current GL context objectnewWidth
- new width in pixelsnewHeight
- new height in pixelsnewByteSize
- if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore.- See Also:
GLPixelBuffer.GLPixelBufferProvider.allocate(GL, PixelFormat.Composition, GLPixelAttributes, boolean, int, int, int, int)
-
dispose
public void dispose()
Dispose resources. SeeisValid()
.
-
-