Class GLPixelBuffer
- Direct Known Subclasses:
AWTGLPixelBuffer
GLPixelBuffer.GLPixelBufferProvider
implementation.
GLPixelBuffer.GLPixelBufferProvider
produces a GLPixelBuffer
.
You may use defaultProviderNoRowStride
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
Pixel attributes.static interface
Allows user to interface with another toolkit to defineGLPixelBuffer.GLPixelAttributes
and memory buffer to produceTextureData
.static interface
SingleGLPixelBuffer
provider. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal boolean
final Buffer
Buffer holding the pixel data.final int
Buffer element size in bytes.final int
Byte size of the buffer.static final GLPixelBuffer.GLPixelBufferProvider
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==false
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
.static final GLPixelBuffer.GLPixelBufferProvider
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==true
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
.final int
Depth in pixels.final int
final boolean
Data packing direction.final int
-
Constructor Summary
ConstructorsConstructorDescriptionGLPixelBuffer
(GLPixelBuffer.GLPixelAttributes pixelAttributes, boolean pack, int width, int height, int depth, Buffer buffer, boolean allowRowStride) -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
Returns the byte capacity of thebuffer
.clear()
SeeBuffer.clear()
.void
dispose()
Dispose resources.flip()
SeeBuffer.flip()
.final boolean
boolean
isValid()
int
limit()
Returns the byte limit of thebuffer
.int
position()
Returns the byte position of thebuffer
.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.rewind()
SeeBuffer.rewind()
.toString()
-
Field Details
-
defaultProviderNoRowStride
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==false
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
. -
defaultProviderWithRowStride
DefaultGLPixelBuffer.GLPixelBufferProvider
withGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
==true
, utilizing best match forGLPixelBuffer.GLPixelAttributes
andallocating
aByteBuffer
. -
pixelAttributes
-
width
public final int widthWidth 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 heightHeight 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 depthDepth in pixels. -
pack
public final boolean packData packing direction.true
for read mode GPU -> CPU, e.g.glReadPixels
.false
for write mode CPU -> GPU, e.g.glTexImage2D
. -
byteSize
public final int byteSizeByte size of the buffer. Actually the number ofBuffer.remaining()
bytes when passed in ctor. -
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 bufferElemSizeBuffer element size in bytes. -
allowRowStride
public final boolean allowRowStride
-
-
Constructor Details
-
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 Details
-
toString
-
toString
-
getAllowRowStride
public final boolean getAllowRowStride() -
isValid
public boolean isValid() -
rewind
SeeBuffer.rewind()
. -
position
public int position()Returns the byte position of thebuffer
. -
position
Sets 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
SeeBuffer.flip()
. -
clear
SeeBuffer.clear()
. -
requiresNewBuffer
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:
-
dispose
public void dispose()Dispose resources. SeeisValid()
.
-