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.GLPixelBufferProviderimplementation.GLPixelBuffer.GLPixelBufferProviderproduces aGLPixelBuffer.You may use
defaultProviderNoRowStride.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGLPixelBuffer.DefaultGLPixelBufferProviderstatic classGLPixelBuffer.GLPixelAttributesPixel attributes.static interfaceGLPixelBuffer.GLPixelBufferProviderAllows user to interface with another toolkit to defineGLPixelBuffer.GLPixelAttributesand memory buffer to produceTextureData.static interfaceGLPixelBuffer.SingletonGLPixelBufferProviderSingleGLPixelBufferprovider.
-
Field Summary
Fields Modifier and Type Field Description booleanallowRowStrideBufferbufferBuffer holding the pixel data.intbufferElemSizeBuffer element size in bytes.intbyteSizeByte size of the buffer.static GLPixelBuffer.GLPixelBufferProviderdefaultProviderNoRowStrideDefaultGLPixelBuffer.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==false, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer.static GLPixelBuffer.GLPixelBufferProviderdefaultProviderWithRowStrideDefaultGLPixelBuffer.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==true, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer.intdepthDepth in pixels.intheightbooleanpackData packing direction.GLPixelBuffer.GLPixelAttributespixelAttributesintwidth
-
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 intcapacity()Returns the byte capacity of thebuffer.Bufferclear()SeeBuffer.clear().voiddispose()Dispose resources.Bufferflip()SeeBuffer.flip().booleangetAllowRowStride()booleanisValid()intlimit()Returns the byte limit of thebuffer.intposition()Returns the byte position of thebuffer.Bufferposition(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.Bufferrewind()SeeBuffer.rewind().StringtoString()StringBuildertoString(StringBuilder sb)
-
-
-
Field Detail
-
defaultProviderNoRowStride
public static final GLPixelBuffer.GLPixelBufferProvider defaultProviderNoRowStride
DefaultGLPixelBuffer.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==false, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer.
-
defaultProviderWithRowStride
public static final GLPixelBuffer.GLPixelBufferProvider defaultProviderWithRowStride
DefaultGLPixelBuffer.GLPixelBufferProviderwithGLPixelBuffer.GLPixelBufferProvider.getAllowRowStride()==true, utilizing best match forGLPixelBuffer.GLPixelAttributesandallocatingaByteBuffer.
-
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.truefor read mode GPU -> CPU, e.g.glReadPixels.falsefor 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 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 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.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 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, 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:
GLPixelBuffer.GLPixelBufferProvider.allocate(GL, PixelFormat.Composition, GLPixelAttributes, boolean, int, int, int, int)
-
dispose
public void dispose()
Dispose resources. SeeisValid().
-
-