public class GLPixelBuffer extends Object
GLPixelBuffer.GLPixelBufferProvider
implementation.
GLPixelBuffer.GLPixelBufferProvider
produces a GLPixelBuffer
.
You may use defaultProviderNoRowStride
.
Modifier and Type | Class and Description |
---|---|
static class |
GLPixelBuffer.DefaultGLPixelBufferProvider |
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. |
Modifier and Type | Field and 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
Default
GLPixelBuffer.GLPixelBufferProvider with GLPixelBuffer.GLPixelBufferProvider.getAllowRowStride() == false ,
utilizing best match for GLPixelBuffer.GLPixelAttributes
and allocating a ByteBuffer . |
static GLPixelBuffer.GLPixelBufferProvider |
defaultProviderWithRowStride
Default
GLPixelBuffer.GLPixelBufferProvider with GLPixelBuffer.GLPixelBufferProvider.getAllowRowStride() == true ,
utilizing best match for GLPixelBuffer.GLPixelAttributes
and allocating a ByteBuffer . |
int |
depth
Depth in pixels.
|
int |
height
|
boolean |
pack
Data packing direction.
|
GLPixelBuffer.GLPixelAttributes |
pixelAttributes
|
int |
width
|
Constructor and Description |
---|
GLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes,
boolean pack,
int width,
int height,
int depth,
Buffer buffer,
boolean allowRowStride) |
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Returns the byte capacity of the
buffer . |
Buffer |
clear()
See
Buffer.clear() . |
void |
dispose()
Dispose resources.
|
Buffer |
flip()
See
Buffer.flip() . |
boolean |
getAllowRowStride()
|
boolean |
isValid()
|
int |
limit()
Returns the byte limit of the
buffer . |
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 newByteSize)
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()
See
Buffer.rewind() . |
String |
toString() |
StringBuilder |
toString(StringBuilder sb) |
public static final GLPixelBuffer.GLPixelBufferProvider defaultProviderNoRowStride
GLPixelBuffer.GLPixelBufferProvider
with GLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
== false
,
utilizing best match for GLPixelBuffer.GLPixelAttributes
and allocating
a ByteBuffer
.public static final GLPixelBuffer.GLPixelBufferProvider defaultProviderWithRowStride
GLPixelBuffer.GLPixelBufferProvider
with GLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
== true
,
utilizing best match for GLPixelBuffer.GLPixelAttributes
and allocating
a ByteBuffer
.public final GLPixelBuffer.GLPixelAttributes pixelAttributes
public final int width
buffer
's byteSize
.
May not represent actual image width as user may re-use buffer for different dimensions, see requiresNewBuffer(GL, int, int, int)
.
public final int height
buffer
's byteSize
.
May not represent actual image height as user may re-use buffer for different dimensions, see requiresNewBuffer(GL, int, int, int)
.
public final int depth
public final boolean pack
true
for read mode GPU -> CPU, e.g. glReadPixels
.
false
for write mode CPU -> GPU, e.g. glTexImage2D
.
public final int byteSize
Buffer.remaining()
bytes when passed in ctor.public final Buffer buffer
rewind()
, it holds byteSize
Buffer.remaining()
bytes.
By default the Buffer
is a ByteBuffer
, due to DefProvider#allocate(GL, PixelFormat.Composition, GLPixelAttributes, boolean, int, int, int, int)
.
However, other GLPixelBuffer.GLPixelBufferProvider
may utilize different Buffer
types.
public final int bufferElemSize
public final boolean allowRowStride
public GLPixelBuffer(GLPixelBuffer.GLPixelAttributes pixelAttributes, boolean pack, int width, int height, int depth, Buffer buffer, boolean allowRowStride)
pixelAttributes
- the desired GLPixelBuffer.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
- If true
, allow row-stride, otherwise not. See requiresNewBuffer(GL, int, int, int)
.hostPixelComp
- the host PixelFormat.Composition
public StringBuilder toString(StringBuilder sb)
public final boolean getAllowRowStride()
public boolean isValid()
public Buffer rewind()
Buffer.rewind()
.public int position()
buffer
.public int capacity()
buffer
.public int limit()
buffer
.public Buffer flip()
Buffer.flip()
.public Buffer clear()
Buffer.clear()
.public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int newByteSize)
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 GLBuffers.sizeof(..)
is being used to calculate it. This value is referred to newByteSize.
If
,
method returns allowRowStride
= falsetrue
if the newByteSize > currentByteSize
or the newWidth
!= currentWidth
.
If
, see allowRowStride
= trueGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()
,
method returns true
only if the newByteSize > currentByteSize.
Assuming user utilizes the row-stride when dealing w/ the data, i.e. GL2ES3.GL_PACK_ROW_LENGTH
.
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.GLPixelBufferProvider#allocate(GL, PixelFormat.Composition, GLPixelAttributes, boolean, int, int, int, int)
public void dispose()
isValid()
.Copyright 2010 JogAmp Community.