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 classstatic classPixel attributes.static interfaceAllows user to interface with another toolkit to defineGLPixelBuffer.GLPixelAttributesand memory buffer to produceTextureData.static interfaceSingleGLPixelBufferprovider. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanfinal BufferBuffer holding the pixel data.final intBuffer element size in bytes.final intByte size of the buffer.static final GLPixelBuffer.GLPixelBufferProviderDefaultGLPixelBuffer.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==false, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer.static final GLPixelBuffer.GLPixelBufferProviderDefaultGLPixelBuffer.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==true, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer.final intDepth in pixels.final intfinal booleanData 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 TypeMethodDescriptionintcapacity()Returns the byte capacity of thebuffer.clear()SeeBuffer.clear().voiddispose()Dispose resources.flip()SeeBuffer.flip().final booleanbooleanisValid()intlimit()Returns the byte limit of thebuffer.intposition()Returns the byte position of thebuffer.position(int bytePos) Sets the byte position of thebuffer.booleanrequiresNewBuffer(GL gl, int newWidth, int newHeight, int newByteSize) Returns true, ifinvalidor 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.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==false, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer. -
defaultProviderWithRowStride
DefaultGLPixelBuffer.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==true, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer. -
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.truefor read mode GPU -> CPU, e.g.glReadPixels.falsefor 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 holdsbyteSizeBuffer.remaining()bytes.By default the
Bufferis aByteBuffer, due toDefProvider#allocate(GL, PixelFormat.Composition, GLPixelAttributes, boolean, int, int, int, int). However, otherGLPixelBuffer.GLPixelBufferProvidermay utilize differentBuffertypes. -
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.GLPixelAttributespack-truefor read mode GPU -> CPU, e.g.glReadPixels.falsefor 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, ifinvalidor implementation requires a new buffer based on the new size due to pixel alignment or byte size, otherwise false.It is assumed that
pixelAttributes,depthandpackstays 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= falsetrueif the newByteSize > currentByteSize or thenewWidth!=currentWidth.If
, seeallowRowStride= trueGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride(), method returnstrueonly 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().
-