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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
address()
Returns the memory address of the internalByteBuffer
.long
address
(int offset) Returns the memory address of the specifiedoffset
.long
addressSafe
(Object value, int offset) Returns the memory address of the specifiedoffset
orNULL
if the specifiedvalue
is null.int
Ensures space for an additional boolean value and returns the address offset.int
booleanParam
(boolean value) Ensures space for an additional boolean value, sets the specified value at the allocated offset and returns that offset.boolean
booleanValue
(int offset) Returns the boolean value at the specified offset.buffer()
Returns theByteBuffer
that backs thisAPIBuffer
.int
bufferParam
(int size) Ensures space for an additional buffer with the specified size (in bytes) and returns the address offset.int
Ensures space for an additional byte value and returns the address offset.int
byteParam
(byte value) Ensures space for an additional byte value, sets the specified value at the allocated offset and returns that offset.byte
byteValue
(int offset) Returns the boolean value at the specified offset.int
Ensures space for an additional double value and returns the address offset.int
doubleParam
(double value) Ensures space for an additional double value, sets the specified value at the allocated offset and returns that offset.double
doubleValue
(int offset) Returns the double value at the specified offset.int
Ensures space for an additional float value and returns the address offset.int
floatParam
(float value) Ensures space for an additional float value, sets the specified value at the allocated offset and returns that offset.float
floatValue
(int offset) Returns the float value at the specified offset.int
Returns the current parameter offset.int
intParam()
Ensures space for an additional int value and returns the address offset.int
intParam
(int value) Ensures space for an additional int value, sets the specified value at the allocated offset and returns that offset.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.int
intValue
(int offset) Returns the int value at the specified offset.int
Ensures space for an additional long value and returns the address offset.int
longParam
(long value) Ensures space for an additional long value, sets the specified value at the allocated offset and returns that offset.long
longValue
(int offset) Returns the long value at the specified offset.void
pointerArrayFree
(int offset, int length) Freeslength
memory blocks stored in the APIBuffer, starting at the specifiedoffset
.int
pointerArrayParam
(long... pointers) Ensures space for an additional pointer buffer, sets the specified memory addresses and returns the address offset.int
pointerArrayParam
(ByteBuffer... buffers) Ensures space for an additional pointer buffer, sets the memory addresses of the specified buffers and returns the address offset.int
pointerArrayParamASCII
(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.int
pointerArrayParamASCIIi
(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.int
pointerArrayParamASCIIp
(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.int
pointerArrayParamp
(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.int
pointerArrayParamUTF16
(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.int
pointerArrayParamUTF16i
(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.int
pointerArrayParamUTF16p
(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.int
pointerArrayParamUTF8
(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.int
pointerArrayParamUTF8i
(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.int
pointerArrayParamUTF8p
(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.int
Ensures space for an additional pointer value and returns the address offset.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.int
pointerParam
(long value) Ensures space for an additional pointer value, sets the specified value at the allocated offset and returns that offset.long
pointerValue
(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.void
setOffset
(int offset) Sets the current parameter offset.int
Ensures space for an additional short value and returns the address offset.int
shortParam
(short value) Ensures space for an additional short value, sets the specified value at the allocated offset and returns that offset.short
shortValue
(int offset) Returns the short value at the specified offset.int
stringParamASCII
(CharSequence value, boolean nullTerminated) Ensures space for the specified string encoded in ASCII, encodes the string at the allocated offset and returns that offset.int
stringParamUTF16
(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.int
stringParamUTF8
(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
-
APIBuffer
public APIBuffer()
-
-
Method Details
-
reset
Resets the parameter offset to 0. -
push
Pushes the current parameter offset to a stack. -
pop
Restores the last pushed parameter offset. -
getOffset
public int getOffset()Returns the current parameter offset. -
setOffset
public void setOffset(int offset) Sets the current parameter offset. -
address
public long address()Returns the memory address of the internalByteBuffer
. This address may change after a call to one of the<type>Param()
methods. -
address
public 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. -
addressSafe
Returns the memory address of the specifiedoffset
orNULL
if the specifiedvalue
is null. This address may change after a call to one of the<type>Param()
methods. -
buffer
Returns theByteBuffer
that backs thisAPIBuffer
. -
booleanParam
public int booleanParam()Ensures space for an additional boolean value and returns the address offset. -
byteParam
public int byteParam()Ensures space for an additional byte value and returns the address offset. -
shortParam
public int shortParam()Ensures space for an additional short value and returns the address offset. -
intParam
public int intParam()Ensures space for an additional int value and returns the address offset. -
longParam
public int longParam()Ensures space for an additional long value and returns the address offset. -
floatParam
public int floatParam()Ensures space for an additional float value and returns the address offset. -
doubleParam
public int doubleParam()Ensures space for an additional double value and returns the address offset. -
pointerParam
public int pointerParam()Ensures space for an additional pointer value and returns the address offset. -
bufferParam
public int bufferParam(int size) Ensures space for an additional buffer with the specified size (in bytes) and returns the address offset. -
booleanParam
public int booleanParam(boolean value) Ensures space for an additional boolean value, sets the specified value at the allocated offset and returns that offset. -
byteParam
public int byteParam(byte value) Ensures space for an additional byte value, sets the specified value at the allocated offset and returns that offset. -
shortParam
public int shortParam(short value) Ensures space for an additional short value, sets the specified value at the allocated offset and returns that offset. -
intParam
public int intParam(int value) Ensures space for an additional int value, sets the specified value at the allocated offset and returns that offset. -
longParam
public int longParam(long value) Ensures space for an additional long value, sets the specified value at the allocated offset and returns that offset. -
floatParam
public int floatParam(float value) Ensures space for an additional float value, sets the specified value at the allocated offset and returns that offset. -
doubleParam
public int doubleParam(double value) Ensures space for an additional double value, sets the specified value at the allocated offset and returns that offset. -
pointerParam
public int pointerParam(long value) Ensures space for an additional pointer value, sets the specified value at the allocated offset and returns that offset. -
pointerArrayParam
public int pointerArrayParam(long... pointers) Ensures space for an additional pointer buffer, sets the specified memory addresses and returns the address offset. -
pointerArrayParam
Ensures space for an additional pointer buffer, sets the memory addresses of the specified buffers and returns the address offset. -
pointerArrayParamp
Ensures space for two additional pointer buffers, sets the memory addresses and remaining bytes of the specified buffers and returns the address offset. -
pointerArrayParamASCII
ASCII 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
-
pointerArrayParamASCIIi
ASCII 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
-
pointerArrayParamASCIIp
ASCII 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
-
pointerArrayParamUTF8
UTF8 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
-
pointerArrayParamUTF8i
UTF8 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
-
pointerArrayParamUTF8p
UTF8 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
-
pointerArrayParamUTF16
UTF16 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
-
pointerArrayParamUTF16i
UTF16 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
-
pointerArrayParamUTF16p
UTF16 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
-
pointerArrayFree
public void pointerArrayFree(int offset, int length) Freeslength
memory blocks stored in the APIBuffer, starting at the specifiedoffset
. -
intParam
public 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. -
pointerParam
public 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. -
stringParamASCII
Ensures space for the specified string encoded in ASCII, encodes the string at the allocated offset and returns that offset. -
stringParamUTF8
Ensures space for the specified string encoded in UTF-8, encodes the string at the allocated offset and returns that offset. -
stringParamUTF16
Ensures space for the specified string encoded in UTF-16, encodes the string at the allocated offset and returns that offset. -
booleanValue
public boolean booleanValue(int offset) Returns the boolean value at the specified offset. -
byteValue
public byte byteValue(int offset) Returns the boolean value at the specified offset. -
shortValue
public short shortValue(int offset) Returns the short value at the specified offset. -
intValue
public int intValue(int offset) Returns the int value at the specified offset. -
longValue
public long longValue(int offset) Returns the long value at the specified offset. -
floatValue
public float floatValue(int offset) Returns the float value at the specified offset. -
doubleValue
public double doubleValue(int offset) Returns the double value at the specified offset. -
pointerValue
public long pointerValue(int offset) Returns the pointer value at the specified offset. -
stringValueASCII
Returns the ASCII string value at the specified byte range. -
stringValueUTF8
Returns the UTF8 string value at the specified byte range. -
stringValueUTF16
Returns the UTF16 string value at the specified byte range.
-