Package org.lwjgl
Class BufferUtils
- java.lang.Object
-
- org.lwjgl.BufferUtils
-
public final class BufferUtils extends Object
Some often-used Buffer code for creating native buffers of the appropriate size.- Version:
- $Revision$ $Id$
- Author:
- $Author$
-
-
Constructor Summary
Constructors Constructor Description BufferUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ByteBuffer
createByteBuffer(int size)
Construct a direct native-ordered bytebuffer with the specified size.static CharBuffer
createCharBuffer(int size)
Construct a direct native-order charbuffer with the specified number of elements.static DoubleBuffer
createDoubleBuffer(int size)
Construct a direct native-order doublebuffer with the specified number of elements.static FloatBuffer
createFloatBuffer(int size)
Construct a direct native-order floatbuffer with the specified number of elements.static IntBuffer
createIntBuffer(int size)
Construct a direct native-order intbuffer with the specified number of elements.static LongBuffer
createLongBuffer(int size)
Construct a direct native-order longbuffer with the specified number of elements.static PointerBuffer
createPointerBuffer(int size)
Construct a PointerBuffer with the specified number of elements.static ShortBuffer
createShortBuffer(int size)
Construct a direct native-order shortbuffer with the specified number of elements.static int
getElementSizeExponent(Buffer buf)
static int
getOffset(Buffer buffer)
A helper function which is used to get the byte offset in an arbitrary buffer based on its positionstatic void
zeroBuffer(ByteBuffer b)
Fill buffer with zeros from position to remainingstatic void
zeroBuffer(CharBuffer b)
Fill buffer with zeros from position to remainingstatic void
zeroBuffer(DoubleBuffer b)
Fill buffer with zeros from position to remainingstatic void
zeroBuffer(FloatBuffer b)
Fill buffer with zeros from position to remainingstatic void
zeroBuffer(IntBuffer b)
Fill buffer with zeros from position to remainingstatic void
zeroBuffer(LongBuffer b)
Fill buffer with zeros from position to remainingstatic void
zeroBuffer(ShortBuffer b)
Fill buffer with zeros from position to remaining
-
-
-
Method Detail
-
createByteBuffer
public static ByteBuffer createByteBuffer(int size)
Construct a direct native-ordered bytebuffer with the specified size.- Parameters:
size
- The size, in bytes- Returns:
- a ByteBuffer
-
createShortBuffer
public static ShortBuffer createShortBuffer(int size)
Construct a direct native-order shortbuffer with the specified number of elements.- Parameters:
size
- The size, in shorts- Returns:
- a ShortBuffer
-
createCharBuffer
public static CharBuffer createCharBuffer(int size)
Construct a direct native-order charbuffer with the specified number of elements.- Parameters:
size
- The size, in chars- Returns:
- an CharBuffer
-
createIntBuffer
public static IntBuffer createIntBuffer(int size)
Construct a direct native-order intbuffer with the specified number of elements.- Parameters:
size
- The size, in ints- Returns:
- an IntBuffer
-
createLongBuffer
public static LongBuffer createLongBuffer(int size)
Construct a direct native-order longbuffer with the specified number of elements.- Parameters:
size
- The size, in longs- Returns:
- an LongBuffer
-
createFloatBuffer
public static FloatBuffer createFloatBuffer(int size)
Construct a direct native-order floatbuffer with the specified number of elements.- Parameters:
size
- The size, in floats- Returns:
- a FloatBuffer
-
createDoubleBuffer
public static DoubleBuffer createDoubleBuffer(int size)
Construct a direct native-order doublebuffer with the specified number of elements.- Parameters:
size
- The size, in floats- Returns:
- a FloatBuffer
-
createPointerBuffer
public static PointerBuffer createPointerBuffer(int size)
Construct a PointerBuffer with the specified number of elements.- Parameters:
size
- The size, in memory addresses- Returns:
- a PointerBuffer
-
getElementSizeExponent
public static int getElementSizeExponent(Buffer buf)
- Returns:
- n, where buffer_element_size=2^n.
-
getOffset
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:
- the position of the buffer, in BYTES
-
zeroBuffer
public static void zeroBuffer(ByteBuffer b)
Fill buffer with zeros from position to remaining
-
zeroBuffer
public static void zeroBuffer(ShortBuffer b)
Fill buffer with zeros from position to remaining
-
zeroBuffer
public static void zeroBuffer(CharBuffer b)
Fill buffer with zeros from position to remaining
-
zeroBuffer
public static void zeroBuffer(IntBuffer b)
Fill buffer with zeros from position to remaining
-
zeroBuffer
public static void zeroBuffer(FloatBuffer b)
Fill buffer with zeros from position to remaining
-
zeroBuffer
public static void zeroBuffer(LongBuffer b)
Fill buffer with zeros from position to remaining
-
zeroBuffer
public static void zeroBuffer(DoubleBuffer b)
Fill buffer with zeros from position to remaining
-
-