Class BufferUtils
java.lang.Object
com.blackrook.gloop.opengl.util.BufferUtils
Simple utility functions around buffers.
- Author:
- Matthew Tropiano
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe size of a byte in bytes (This should always be 1, or Sun screwed up).static final intThe size of a character in bytes.static final intThe size of a double in bytes.static final intThe size of a float in bytes.static final intThe size of an int in bytes.static final intThe size of a long in bytes.static final intThe size of a short in bytes. -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufferallocDirectByteBuffer(int len) Allocates space for a DIRECT ByteBuffer in native byte order (which really doesn't matter).static CharBufferallocDirectCharBuffer(int len) Allocates space for a DIRECT CharBuffer in native byte orderstatic DoubleBufferallocDirectDoubleBuffer(int len) Allocates space for a DIRECT DoubleBuffer in native byte orderstatic FloatBufferallocDirectFloatBuffer(int len) Allocates space for a DIRECT FloatBuffer in native byte order.static IntBufferallocDirectIntBuffer(int len) Allocates space for a DIRECT IntBuffer in native byte order.static LongBufferallocDirectLongBuffer(int len) Allocates space for a DIRECT LongBuffer in native byte orderstatic ShortBufferallocDirectShortBuffer(int len) Allocates space for a DIRECT ShortBuffer in native byte orderstatic voidprintBuffer(ByteBuffer buffer, PrintStream out) Prints the contents of a buffer to an output print stream.static voidprintBuffer(CharBuffer buffer, PrintStream out) Prints the contents of a buffer to an output print stream.static voidprintBuffer(DoubleBuffer buffer, PrintStream out) Prints the contents of a buffer to an output print stream.static voidprintBuffer(FloatBuffer buffer, PrintStream out) Prints the contents of a buffer to an output print stream.static voidprintBuffer(IntBuffer buffer, PrintStream out) Prints the contents of a buffer to an output print stream.static voidprintBuffer(LongBuffer buffer, PrintStream out) Prints the contents of a buffer to an output print stream.static voidprintBuffer(ShortBuffer buffer, PrintStream out) Prints the contents of a buffer to an output print stream.static ByteBufferwrapDirectBuffer(byte[] b) Allocates a DIRECT ByteBuffer using byte array data.static DoubleBufferwrapDirectBuffer(double[] d) Allocates a DIRECT DoubleBuffer using double array data.static FloatBufferwrapDirectBuffer(float[] f) Allocates a DIRECT FloatBuffer using float array data.static IntBufferwrapDirectBuffer(int[] i) Allocates a DIRECT IntBuffer using int array data.static LongBufferwrapDirectBuffer(long[] l) Allocates a DIRECT LongBuffer using long array data.static ShortBufferwrapDirectBuffer(short[] s) Allocates a DIRECT ShortBuffer using short array data.
-
Field Details
-
SIZEOF_CHAR
public static final int SIZEOF_CHARThe size of a character in bytes.- See Also:
-
SIZEOF_INT
public static final int SIZEOF_INTThe size of an int in bytes.- See Also:
-
SIZEOF_FLOAT
public static final int SIZEOF_FLOATThe size of a float in bytes.- See Also:
-
SIZEOF_BYTE
public static final int SIZEOF_BYTEThe size of a byte in bytes (This should always be 1, or Sun screwed up).- See Also:
-
SIZEOF_SHORT
public static final int SIZEOF_SHORTThe size of a short in bytes.- See Also:
-
SIZEOF_LONG
public static final int SIZEOF_LONGThe size of a long in bytes.- See Also:
-
SIZEOF_DOUBLE
public static final int SIZEOF_DOUBLEThe size of a double in bytes.- See Also:
-
-
Method Details
-
allocDirectByteBuffer
Allocates space for a DIRECT ByteBuffer in native byte order (which really doesn't matter).- Parameters:
len- the length (IN BYTES) of the buffer.- Returns:
- a direct buffer that can hold
lenitems.
-
allocDirectIntBuffer
Allocates space for a DIRECT IntBuffer in native byte order.- Parameters:
len- the length (IN INTS) of the buffer.- Returns:
- a direct buffer that can hold
lenitems.
-
allocDirectFloatBuffer
Allocates space for a DIRECT FloatBuffer in native byte order.- Parameters:
len- the length (IN FLOATS) of the buffer.- Returns:
- a direct buffer that can hold
lenitems.
-
allocDirectLongBuffer
Allocates space for a DIRECT LongBuffer in native byte order- Parameters:
len- the length (IN LONGS) of the buffer.- Returns:
- a direct buffer that can hold
lenitems.
-
allocDirectShortBuffer
Allocates space for a DIRECT ShortBuffer in native byte order- Parameters:
len- the length (IN SHORTS) of the buffer.- Returns:
- a direct buffer that can hold
lenitems.
-
allocDirectCharBuffer
Allocates space for a DIRECT CharBuffer in native byte order- Parameters:
len- the length (IN CHARS) of the buffer.- Returns:
- a direct buffer that can hold
lenitems.
-
allocDirectDoubleBuffer
Allocates space for a DIRECT DoubleBuffer in native byte order- Parameters:
len- the length (IN DOUBLES) of the buffer.- Returns:
- a direct buffer that can hold
lenitems.
-
wrapDirectBuffer
Allocates a DIRECT ByteBuffer using byte array data. Useful for native wrappers that require direct ByteBuffers.- Parameters:
b- the byte array to wrap.- Returns:
- a direct buffer that holds
lenitems.
-
wrapDirectBuffer
Allocates a DIRECT ShortBuffer using short array data. Useful for native wrappers that require direct ShortBuffers.- Parameters:
s- the short array to wrap.- Returns:
- a direct buffer that holds
lenitems.
-
wrapDirectBuffer
Allocates a DIRECT IntBuffer using int array data. Useful for native wrappers that require direct IntBuffers.- Parameters:
i- the int array to wrap.- Returns:
- a direct buffer that holds
lenitems.
-
wrapDirectBuffer
Allocates a DIRECT FloatBuffer using float array data. Useful for native wrappers that require direct FloatBuffers.- Parameters:
f- the float array to wrap.- Returns:
- a direct buffer that holds
lenitems.
-
wrapDirectBuffer
Allocates a DIRECT LongBuffer using long array data. Useful for native wrappers that require direct LongBuffers.- Parameters:
l- the long array to wrap.- Returns:
- a direct buffer that holds
lenitems.
-
wrapDirectBuffer
Allocates a DIRECT DoubleBuffer using double array data. Useful for native wrappers that require direct DoubleBuffers.- Parameters:
d- the double array to wrap.- Returns:
- a direct buffer that holds
lenitems.
-
printBuffer
Prints the contents of a buffer to an output print stream.- Parameters:
buffer- the buffer to print.out- thePrintStreamto output the dump to.
-
printBuffer
Prints the contents of a buffer to an output print stream.- Parameters:
buffer- the buffer to print.out- thePrintStreamto output the dump to.
-
printBuffer
Prints the contents of a buffer to an output print stream.- Parameters:
buffer- the buffer to print.out- thePrintStreamto output the dump to.
-
printBuffer
Prints the contents of a buffer to an output print stream.- Parameters:
buffer- the buffer to print.out- thePrintStreamto output the dump to.
-
printBuffer
Prints the contents of a buffer to an output print stream.- Parameters:
buffer- the buffer to print.out- thePrintStreamto output the dump to.
-
printBuffer
Prints the contents of a buffer to an output print stream.- Parameters:
buffer- the buffer to print.out- thePrintStreamto output the dump to.
-
printBuffer
Prints the contents of a buffer to an output print stream.- Parameters:
buffer- the buffer to print.out- thePrintStreamto output the dump to.
-