Top Description Constructors Methods
org.lwjgl

public final Class BufferUtils

extends Object
Class Inheritance
Imports
java.nio.Buffer, .ByteBuffer, .ByteOrder, .CharBuffer, .DoubleBuffer, .FloatBuffer, .IntBuffer, .LongBuffer, .ShortBuffer

Some often-used Buffer code for creating native buffers of the appropriate size.
Author
$Author$
Version
$Revision$ $Id$

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ByteBuffer

Returns:

a ByteBuffer
createByteBuffer
(int
The size, in bytes
size
)

Construct a direct native-ordered bytebuffer with the specified size.

public static CharBuffer

Returns:

an CharBuffer
createCharBuffer
(int
The size, in chars
size
)

Construct a direct native-order charbuffer with the specified number of elements.

public static DoubleBuffer

Returns:

a FloatBuffer
createDoubleBuffer
(int
The size, in floats
size
)

Construct a direct native-order doublebuffer with the specified number of elements.

public static FloatBuffer

Returns:

a FloatBuffer
createFloatBuffer
(int
The size, in floats
size
)

Construct a direct native-order floatbuffer with the specified number of elements.

public static IntBuffer

Returns:

an IntBuffer
createIntBuffer
(int
The size, in ints
size
)

Construct a direct native-order intbuffer with the specified number of elements.

public static LongBuffer

Returns:

an LongBuffer
createLongBuffer
(int
The size, in longs
size
)

Construct a direct native-order longbuffer with the specified number of elements.

public static PointerBuffer

Returns:

a PointerBuffer
createPointerBuffer
(int
The size, in memory addresses
size
)

Construct a PointerBuffer with the specified number of elements.

public static ShortBuffer

Returns:

a ShortBuffer
createShortBuffer
(int
The size, in shorts
size
)

Construct a direct native-order shortbuffer with the specified number of elements.

pack-priv static native long

Returns:

the memory address
getBufferAddress
(Buffer
the buffer
buffer
)

Returns the memory address of the specified buffer.

public static int

Returns:

n, where buffer_element_size=2^n.
getElementSizeExponent
(Buffer buf)

public static int

Returns:

the position of the buffer, in BYTES
getOffset
(Buffer buffer)

A helper function which is used to get the byte offset in an arbitrary buffer based on its position

public static void
zeroBuffer(ByteBuffer b)

Fill buffer with zeros from position to remaining

public static void
zeroBuffer(ShortBuffer b)

Fill buffer with zeros from position to remaining

public static void
zeroBuffer(CharBuffer b)

Fill buffer with zeros from position to remaining

public static void
zeroBuffer(IntBuffer b)

Fill buffer with zeros from position to remaining

public static void
zeroBuffer(FloatBuffer b)

Fill buffer with zeros from position to remaining

public static void
zeroBuffer(LongBuffer b)

Fill buffer with zeros from position to remaining

public static void
zeroBuffer(DoubleBuffer b)

Fill buffer with zeros from position to remaining

private static native void
zeroBuffer0(Buffer b, long off, long size)

Fill buffer with zeros from position to remaining

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

BufferUtilsback to summary
public BufferUtils()

Method Detail

createByteBufferback to summary
public static ByteBuffer createByteBuffer(int size)

Construct a direct native-ordered bytebuffer with the specified size.

Parameters
size:int

The size, in bytes

Returns:ByteBuffer

a ByteBuffer

createCharBufferback to summary
public static CharBuffer createCharBuffer(int size)

Construct a direct native-order charbuffer with the specified number of elements.

Parameters
size:int

The size, in chars

Returns:CharBuffer

an CharBuffer

createDoubleBufferback to summary
public static DoubleBuffer createDoubleBuffer(int size)

Construct a direct native-order doublebuffer with the specified number of elements.

Parameters
size:int

The size, in floats

Returns:DoubleBuffer

a FloatBuffer

createFloatBufferback to summary
public static FloatBuffer createFloatBuffer(int size)

Construct a direct native-order floatbuffer with the specified number of elements.

Parameters
size:int

The size, in floats

Returns:FloatBuffer

a FloatBuffer

createIntBufferback to summary
public static IntBuffer createIntBuffer(int size)

Construct a direct native-order intbuffer with the specified number of elements.

Parameters
size:int

The size, in ints

Returns:IntBuffer

an IntBuffer

createLongBufferback to summary
public static LongBuffer createLongBuffer(int size)

Construct a direct native-order longbuffer with the specified number of elements.

Parameters
size:int

The size, in longs

Returns:LongBuffer

an LongBuffer

createPointerBufferback to summary
public static PointerBuffer createPointerBuffer(int size)

Construct a PointerBuffer with the specified number of elements.

Parameters
size:int

The size, in memory addresses

Returns:PointerBuffer

a PointerBuffer

createShortBufferback to summary
public static ShortBuffer createShortBuffer(int size)

Construct a direct native-order shortbuffer with the specified number of elements.

Parameters
size:int

The size, in shorts

Returns:ShortBuffer

a ShortBuffer

getBufferAddressback to summary
pack-priv static native long getBufferAddress(Buffer buffer)

Returns the memory address of the specified buffer.

Parameters
buffer:Buffer

the buffer

Returns:long

the memory address

getElementSizeExponentback to summary
public static int getElementSizeExponent(Buffer buf)
Returns:int

n, where buffer_element_size=2^n.

getOffsetback to summary
public static int getOffset(Buffer buffer)

A helper function which is used to get the byte offset in an arbitrary buffer based on its position

Returns:int

the position of the buffer, in BYTES

zeroBufferback to summary
public static void zeroBuffer(ByteBuffer b)

Fill buffer with zeros from position to remaining

zeroBufferback to summary
public static void zeroBuffer(ShortBuffer b)

Fill buffer with zeros from position to remaining

zeroBufferback to summary
public static void zeroBuffer(CharBuffer b)

Fill buffer with zeros from position to remaining

zeroBufferback to summary
public static void zeroBuffer(IntBuffer b)

Fill buffer with zeros from position to remaining

zeroBufferback to summary
public static void zeroBuffer(FloatBuffer b)

Fill buffer with zeros from position to remaining

zeroBufferback to summary
public static void zeroBuffer(LongBuffer b)

Fill buffer with zeros from position to remaining

zeroBufferback to summary
public static void zeroBuffer(DoubleBuffer b)

Fill buffer with zeros from position to remaining

zeroBuffer0back to summary
private static native void zeroBuffer0(Buffer b, long off, long size)

Fill buffer with zeros from position to remaining