Package com.jme3.lwjgl3.utils
Class APIBuffer
java.lang.Object
com.jme3.lwjgl3.utils.APIBuffer
Helper class for alternative API functions. Instead of the user passing their
 own buffer, thread-local instances of this class are used internally instead.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionlongaddress()Returns the memory address of the internalByteBuffer.longaddress(int offset) Returns the memory address of the specifiedoffset.longaddressSafe(Object value, int offset) Returns the memory address of the specifiedoffsetorNULLif the specifiedvalueis null.intEnsures space for an additional boolean value and returns the address offset.intbooleanParam(boolean value) Ensures space for an additional boolean value, sets the specified value at the allocated offset and returns that offset.booleanbooleanValue(int offset) Returns the boolean value at the specified offset.buffer()Returns theByteBufferthat backs thisAPIBuffer.intbufferParam(int size) Ensures space for an additional buffer with the specified size (in bytes) and returns the address offset.intEnsures space for an additional byte value and returns the address offset.intbyteParam(byte value) Ensures space for an additional byte value, sets the specified value at the allocated offset and returns that offset.bytebyteValue(int offset) Returns the boolean value at the specified offset.intEnsures space for an additional double value and returns the address offset.intdoubleParam(double value) Ensures space for an additional double value, sets the specified value at the allocated offset and returns that offset.doubledoubleValue(int offset) Returns the double value at the specified offset.intEnsures space for an additional float value and returns the address offset.intfloatParam(float value) Ensures space for an additional float value, sets the specified value at the allocated offset and returns that offset.floatfloatValue(int offset) Returns the float value at the specified offset.intReturns the current parameter offset.intintParam()Ensures space for an additional int value and returns the address offset.intintParam(int value) Ensures space for an additional int value, sets the specified value at the allocated offset and returns that offset.voidintParam(int offset, int index, int value) Sets an int value at the specified index of the int buffer that starts at the specified offset.intintValue(int offset) Returns the int value at the specified offset.intEnsures space for an additional long value and returns the address offset.intlongParam(long value) Ensures space for an additional long value, sets the specified value at the allocated offset and returns that offset.longlongValue(int offset) Returns the long value at the specified offset.voidpointerArrayFree(int offset, int length) Freeslengthmemory blocks stored in the APIBuffer, starting at the specifiedoffset.intpointerArrayParam(long... pointers) Ensures space for an additional pointer buffer, sets the specified memory addresses and returns the address offset.intpointerArrayParam(ByteBuffer... buffers) Ensures space for an additional pointer buffer, sets the memory addresses of the specified buffers and returns the address offset.intpointerArrayParamASCII(CharSequence... strings) ASCII encodes the specified strings with a null-terminator and ensures space for a buffer filled with the memory addresses of the encoded strings.intpointerArrayParamASCIIi(CharSequence... strings) ASCII encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively.intpointerArrayParamASCIIp(CharSequence... strings) ASCII encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively.intpointerArrayParamp(ByteBuffer... buffers) Ensures space for two additional pointer buffers, sets the memory addresses and remaining bytes of the specified buffers and returns the address offset.intpointerArrayParamUTF16(CharSequence... strings) UTF16 encodes the specified strings with a null-terminator and ensures space for a buffer filled with the memory addresses of the encoded strings.intpointerArrayParamUTF16i(CharSequence... strings) UTF16 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively.intpointerArrayParamUTF16p(CharSequence... strings) UTF16 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively.intpointerArrayParamUTF8(CharSequence... strings) UTF8 encodes the specified strings with a null-terminator and ensures space for a buffer filled with the memory addresses of the encoded strings.intpointerArrayParamUTF8i(CharSequence... strings) UTF8 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively.intpointerArrayParamUTF8p(CharSequence... strings) UTF8 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively.intEnsures space for an additional pointer value and returns the address offset.voidpointerParam(int offset, int index, long value) Sets a pointer value at the specified index of the pointer buffer that starts at the specified offset.intpointerParam(long value) Ensures space for an additional pointer value, sets the specified value at the allocated offset and returns that offset.longpointerValue(int offset) Returns the pointer value at the specified offset.pop()Restores the last pushed parameter offset.push()Pushes the current parameter offset to a stack.reset()Resets the parameter offset to 0.voidsetOffset(int offset) Sets the current parameter offset.intEnsures space for an additional short value and returns the address offset.intshortParam(short value) Ensures space for an additional short value, sets the specified value at the allocated offset and returns that offset.shortshortValue(int offset) Returns the short value at the specified offset.intstringParamASCII(CharSequence value, boolean nullTerminated) Ensures space for the specified string encoded in ASCII, encodes the string at the allocated offset and returns that offset.intstringParamUTF16(CharSequence value, boolean nullTerminated) Ensures space for the specified string encoded in UTF-16, encodes the string at the allocated offset and returns that offset.intstringParamUTF8(CharSequence value, boolean nullTerminated) Ensures space for the specified string encoded in UTF-8, encodes the string at the allocated offset and returns that offset.stringValueASCII(int offset, int limit) Returns the ASCII string value at the specified byte range.stringValueUTF16(int offset, int limit) Returns the UTF16 string value at the specified byte range.stringValueUTF8(int offset, int limit) Returns the UTF8 string value at the specified byte range.
- 
Constructor Details- 
APIBufferpublic APIBuffer()
 
- 
- 
Method Details- 
resetResets the parameter offset to 0.
- 
pushPushes the current parameter offset to a stack.
- 
popRestores the last pushed parameter offset.
- 
getOffsetpublic int getOffset()Returns the current parameter offset.
- 
setOffsetpublic void setOffset(int offset) Sets the current parameter offset.
- 
addresspublic long address()Returns the memory address of the internalByteBuffer. This address may change after a call to one of the<type>Param()methods.
- 
addresspublic long address(int offset) Returns the memory address of the specifiedoffset. This address may change after a call to one of the<type>Param()methods.
- 
addressSafeReturns the memory address of the specifiedoffsetorNULLif the specifiedvalueis null. This address may change after a call to one of the<type>Param()methods.
- 
bufferReturns theByteBufferthat backs thisAPIBuffer.
- 
booleanParampublic int booleanParam()Ensures space for an additional boolean value and returns the address offset.
- 
byteParampublic int byteParam()Ensures space for an additional byte value and returns the address offset.
- 
shortParampublic int shortParam()Ensures space for an additional short value and returns the address offset.
- 
intParampublic int intParam()Ensures space for an additional int value and returns the address offset.
- 
longParampublic int longParam()Ensures space for an additional long value and returns the address offset.
- 
floatParampublic int floatParam()Ensures space for an additional float value and returns the address offset.
- 
doubleParampublic int doubleParam()Ensures space for an additional double value and returns the address offset.
- 
pointerParampublic int pointerParam()Ensures space for an additional pointer value and returns the address offset.
- 
bufferParampublic int bufferParam(int size) Ensures space for an additional buffer with the specified size (in bytes) and returns the address offset.
- 
booleanParampublic int booleanParam(boolean value) Ensures space for an additional boolean value, sets the specified value at the allocated offset and returns that offset.
- 
byteParampublic int byteParam(byte value) Ensures space for an additional byte value, sets the specified value at the allocated offset and returns that offset.
- 
shortParampublic int shortParam(short value) Ensures space for an additional short value, sets the specified value at the allocated offset and returns that offset.
- 
intParampublic int intParam(int value) Ensures space for an additional int value, sets the specified value at the allocated offset and returns that offset.
- 
longParampublic int longParam(long value) Ensures space for an additional long value, sets the specified value at the allocated offset and returns that offset.
- 
floatParampublic int floatParam(float value) Ensures space for an additional float value, sets the specified value at the allocated offset and returns that offset.
- 
doubleParampublic int doubleParam(double value) Ensures space for an additional double value, sets the specified value at the allocated offset and returns that offset.
- 
pointerParampublic int pointerParam(long value) Ensures space for an additional pointer value, sets the specified value at the allocated offset and returns that offset.
- 
pointerArrayParampublic int pointerArrayParam(long... pointers) Ensures space for an additional pointer buffer, sets the specified memory addresses and returns the address offset.
- 
pointerArrayParamEnsures space for an additional pointer buffer, sets the memory addresses of the specified buffers and returns the address offset.
- 
pointerArrayParampEnsures space for two additional pointer buffers, sets the memory addresses and remaining bytes of the specified buffers and returns the address offset.
- 
pointerArrayParamASCIIASCII encodes the specified strings with a null-terminator and ensures space for a buffer filled with the memory addresses of the encoded strings.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the memory address buffer
 
- 
pointerArrayParamASCIIiASCII encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively. The lengths are 4-bytes integers and the memory address buffer starts immediately after the lengths buffer.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the lengths buffer
 
- 
pointerArrayParamASCIIpASCII encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively. The lengths are pointer-sized integers and the memory address buffer starts immediately after the lengths buffer.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the lengths buffer
 
- 
pointerArrayParamUTF8UTF8 encodes the specified strings with a null-terminator and ensures space for a buffer filled with the memory addresses of the encoded strings.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the memory address buffer
 
- 
pointerArrayParamUTF8iUTF8 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively. The lengths are 4-bytes integers and the memory address buffer starts immediately after the lengths buffer.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the lengths buffer
 
- 
pointerArrayParamUTF8pUTF8 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively. The lengths are pointer-sized integers and the memory address buffer starts immediately after the lengths buffer.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the lengths buffer
 
- 
pointerArrayParamUTF16UTF16 encodes the specified strings with a null-terminator and ensures space for a buffer filled with the memory addresses of the encoded strings.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the memory address buffer
 
- 
pointerArrayParamUTF16iUTF16 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively. The lengths are 4-bytes integers and the memory address buffer starts immediately after the lengths buffer.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the lengths buffer
 
- 
pointerArrayParamUTF16pUTF16 encodes the specified strings and ensures space for two additional buffers filled with the lengths and memory addresses of the encoded strings, respectively. The lengths are pointer-sized integers and the memory address buffer starts immediately after the lengths buffer.The encoded buffers must be later freed with pointerArrayFree(int, int).- Returns:
- the offset to the lengths buffer
 
- 
pointerArrayFreepublic void pointerArrayFree(int offset, int length) Freeslengthmemory blocks stored in the APIBuffer, starting at the specifiedoffset.
- 
intParampublic void intParam(int offset, int index, int value) Sets an int value at the specified index of the int buffer that starts at the specified offset.
- 
pointerParampublic void pointerParam(int offset, int index, long value) Sets a pointer value at the specified index of the pointer buffer that starts at the specified offset.
- 
stringParamASCIIEnsures space for the specified string encoded in ASCII, encodes the string at the allocated offset and returns that offset.
- 
stringParamUTF8Ensures space for the specified string encoded in UTF-8, encodes the string at the allocated offset and returns that offset.
- 
stringParamUTF16Ensures space for the specified string encoded in UTF-16, encodes the string at the allocated offset and returns that offset.
- 
booleanValuepublic boolean booleanValue(int offset) Returns the boolean value at the specified offset.
- 
byteValuepublic byte byteValue(int offset) Returns the boolean value at the specified offset.
- 
shortValuepublic short shortValue(int offset) Returns the short value at the specified offset.
- 
intValuepublic int intValue(int offset) Returns the int value at the specified offset.
- 
longValuepublic long longValue(int offset) Returns the long value at the specified offset.
- 
floatValuepublic float floatValue(int offset) Returns the float value at the specified offset.
- 
doubleValuepublic double doubleValue(int offset) Returns the double value at the specified offset.
- 
pointerValuepublic long pointerValue(int offset) Returns the pointer value at the specified offset.
- 
stringValueASCIIReturns the ASCII string value at the specified byte range.
- 
stringValueUTF8Returns the UTF8 string value at the specified byte range.
- 
stringValueUTF16Returns the UTF16 string value at the specified byte range.
 
-