APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.utils

public final Class BufferUtils

extends Object
Class Inheritance
Imports
java.nio.Buffer, .ByteBuffer, .ByteOrder, .CharBuffer, .DoubleBuffer, .FloatBuffer, .IntBuffer, .LongBuffer, .ShortBuffer, com.badlogic.gdx.math.Matrix3, .Matrix4

Class with static helper methods to increase the speed of array/direct buffer and direct buffer/direct buffer transfers
Author
mzechner, xoppa

Field Summary

Modifier and TypeField and Description
pack-priv static int
pack-priv static Array<ByteBuffer>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static int
bytesToElements(Buffer dst, int bytes)

public static native void
clear(ByteBuffer buffer, int numBytes)

Writes the specified number of zeros to the buffer.

public static void
copy(float[]
the source array
src
,
Buffer
the destination buffer, has to be a direct Buffer
dst
,
int
the number of floats to copy
numFloats
,
int
the offset in src to start copying from
offset
)

Copies numFloats floats from src starting at offset to dst.

public static void
copy(byte[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
Buffer
the destination Buffer, its position is used as an offset.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(short[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
Buffer
the destination Buffer, its position is used as an offset.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(char[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
int
the number of elements to copy.
numElements
,
Buffer
the destination Buffer, its position is used as an offset.
dst
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(int[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
int
the number of elements to copy.
numElements
,
Buffer
the destination Buffer, its position is used as an offset.
dst
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(long[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
int
the number of elements to copy.
numElements
,
Buffer
the destination Buffer, its position is used as an offset.
dst
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(float[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
int
the number of elements to copy.
numElements
,
Buffer
the destination Buffer, its position is used as an offset.
dst
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(double[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
int
the number of elements to copy.
numElements
,
Buffer
the destination Buffer, its position is used as an offset.
dst
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(char[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
Buffer
the destination Buffer, its position is used as an offset.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(int[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
Buffer
the destination Buffer, its position is used as an offset.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(long[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
Buffer
the destination Buffer, its position is used as an offset.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(float[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
Buffer
the destination Buffer, its position is used as an offset.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(double[]
the source array.
src
,
int
the offset into the source array.
srcOffset
,
Buffer
the destination Buffer, its position is used as an offset.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements.

public static void
copy(Buffer
the source Buffer.
src
,
Buffer
the destination Buffer.
dst
,
int
the number of elements to copy.
numElements
)

Copies the contents of src to dst, starting from the current position of src, copying numElements elements (using the data type of src, no matter the datatype of dst).

private static native void
copyJni(float[] src, Buffer dst, int numFloats, int offset)

private static native void
copyJni(byte[] src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

private static native void
copyJni(char[] src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

private static native void
copyJni(short[] src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

private static native void
copyJni(int[] src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

private static native void
copyJni(long[] src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

private static native void
copyJni(float[] src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

private static native void
copyJni(double[] src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

private static native void
copyJni(Buffer src, int srcOffset, Buffer dst, int dstOffset, int numBytes)

public static void
private static int
elementsToBytes(Buffer dst, int elements)

private static native long
find(Buffer vertex, int vertexOffsetInBytes, int strideInBytes, Buffer vertices, int verticesOffsetInBytes, int numVertices)

private static native long
find(float[] vertex, int vertexOffsetInBytes, int strideInBytes, Buffer vertices, int verticesOffsetInBytes, int numVertices)

private static native long
find(Buffer vertex, int vertexOffsetInBytes, int strideInBytes, float[] vertices, int verticesOffsetInBytes, int numVertices)

private static native long
find(float[] vertex, int vertexOffsetInBytes, int strideInBytes, float[] vertices, int verticesOffsetInBytes, int numVertices)

private static native long
find(Buffer vertex, int vertexOffsetInBytes, int strideInBytes, Buffer vertices, int verticesOffsetInBytes, int numVertices, float epsilon)

private static native long
find(float[] vertex, int vertexOffsetInBytes, int strideInBytes, Buffer vertices, int verticesOffsetInBytes, int numVertices, float epsilon)

private static native long
find(Buffer vertex, int vertexOffsetInBytes, int strideInBytes, float[] vertices, int verticesOffsetInBytes, int numVertices, float epsilon)

private static native long
find(float[] vertex, int vertexOffsetInBytes, int strideInBytes, float[] vertices, int verticesOffsetInBytes, int numVertices, float epsilon)

public static long
findFloats(Buffer vertex, int strideInBytes, Buffer vertices, int numVertices)

public static long
findFloats(float[] vertex, int strideInBytes, Buffer vertices, int numVertices)

public static long
findFloats(Buffer vertex, int strideInBytes, float[] vertices, int numVertices)

public static long
findFloats(float[] vertex, int strideInBytes, float[] vertices, int numVertices)

public static long
findFloats(Buffer vertex, int strideInBytes, Buffer vertices, int numVertices, float epsilon)

public static long
findFloats(float[] vertex, int strideInBytes, Buffer vertices, int numVertices, float epsilon)

public static long
findFloats(Buffer vertex, int strideInBytes, float[] vertices, int numVertices, float epsilon)

public static long
findFloats(float[] vertex, int strideInBytes, float[] vertices, int numVertices, float epsilon)

private static native void
freeMemory(ByteBuffer buffer)

Frees the memory allocated for the ByteBuffer, which MUST have been allocated via newUnsafeByteBuffer(ByteBuffer) or in native code.

public static int
getAllocatedBytesUnsafe()

Returns: the number of bytes allocated with newUnsafeByteBuffer(int)

private static native long
public static long

Returns:

the address of the Buffer.
getUnsafeBufferAddress
(Buffer
The Buffer to ask the address for.
buffer
)

Returns the address of the Buffer, it assumes it is an unsafe buffer.

public static boolean
public static ByteBuffer
newByteBuffer(int numBytes)

public static CharBuffer
newCharBuffer(int numChars)

private static native ByteBuffer
public static DoubleBuffer
newDoubleBuffer(int numDoubles)

public static FloatBuffer
newFloatBuffer(int numFloats)

public static IntBuffer
newIntBuffer(int numInts)

public static LongBuffer
newLongBuffer(int numLongs)

public static ShortBuffer
newShortBuffer(int numShorts)

public static ByteBuffer
newUnsafeByteBuffer(int numBytes)

Allocates a new direct ByteBuffer from native heap memory using the native byte order.

public static ByteBuffer

Returns:

the ByteBuffer passed to the method
newUnsafeByteBuffer
(ByteBuffer
the ByteBuffer to register
buffer
)

Registers the given ByteBuffer as an unsafe ByteBuffer.

private static int
public static void
transform(Buffer
The buffer to transform.
data
,
int
The number of components of the vector (2 for xy, 3 for xyz or 4 for xyzw)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix4
The matrix to multiply the vector with
matrix
)

Multiply float vector components within the buffer with the specified matrix.

public static void
transform(float[]
The buffer to transform.
data
,
int
The number of components of the vector (2 for xy, 3 for xyz or 4 for xyzw)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix4
The matrix to multiply the vector with
matrix
)

Multiply float vector components within the buffer with the specified matrix.

public static void
transform(Buffer
The buffer to transform.
data
,
int
The number of components of the vector (2 for xy, 3 for xyz or 4 for xyzw)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix4
The matrix to multiply the vector with
matrix
,
int
The offset within the buffer (in bytes relative to the current position) to the vector
offset
)

Multiply float vector components within the buffer with the specified matrix.

public static void
transform(float[]
The buffer to transform.
data
,
int
The number of components of the vector (2 for xy, 3 for xyz or 4 for xyzw)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix4
The matrix to multiply the vector with
matrix
,
int
The offset within the buffer (in bytes relative to the current position) to the vector
offset
)

Multiply float vector components within the buffer with the specified matrix.

public static void
transform(Buffer
The buffer to transform.
data
,
int
The number of components (x, y, z) of the vector (2 for xy or 3 for xyz)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix3
The matrix to multiply the vector with
matrix
)

Multiply float vector components within the buffer with the specified matrix.

public static void
transform(float[]
The buffer to transform.
data
,
int
The number of components (x, y, z) of the vector (2 for xy or 3 for xyz)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix3
The matrix to multiply the vector with
matrix
)

Multiply float vector components within the buffer with the specified matrix.

public static void
transform(Buffer
The buffer to transform.
data
,
int
The number of components (x, y, z) of the vector (2 for xy or 3 for xyz)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix3
The matrix to multiply the vector with,
matrix
,
int
The offset within the buffer (in bytes relative to the current position) to the vector
offset
)

Multiply float vector components within the buffer with the specified matrix.

public static void
transform(float[]
The buffer to transform.
data
,
int
The number of components (x, y, z) of the vector (2 for xy or 3 for xyz)
dimensions
,
int
The offset between the first and the second vector to transform
strideInBytes
,
int
The number of vectors to transform
count
,
Matrix3
The matrix to multiply the vector with,
matrix
,
int
The offset within the buffer (in bytes relative to the current position) to the vector
offset
)

Multiply float vector components within the buffer with the specified matrix.

private static native void
transformV2M3Jni(Buffer data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV2M3Jni(float[] data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV2M4Jni(Buffer data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV2M4Jni(float[] data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV3M3Jni(Buffer data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV3M3Jni(float[] data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV3M4Jni(Buffer data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV3M4Jni(float[] data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV4M4Jni(Buffer data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

private static native void
transformV4M4Jni(float[] data, int strideInBytes, int count, float[] matrix, int offsetInBytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait