de.javagl.swogl
Class BufferUtils

java.lang.Object
  extended by de.javagl.swogl.BufferUtils

public class BufferUtils
extends java.lang.Object

Utility methods for buffers


Method Summary
static java.nio.ByteBuffer createByteBuffer(int size)
          Create a direct byte buffer with the given size
static java.nio.ByteBuffer createDirectBuffer(byte[] a)
          Create a direct byte buffer which has the contents of the given array.
static java.nio.FloatBuffer createDirectBuffer(float[] a)
          Create a direct float buffer which has the contents of the given array.
static java.nio.IntBuffer createDirectBuffer(int[] a)
          Create a direct int buffer which has the contents of the given array.
static java.nio.FloatBuffer createFloatBuffer(int size)
          Create a direct float buffer with the given size
static java.nio.IntBuffer createIntBuffer(int size)
          Create a direct int buffer with the given size
static java.nio.FloatBuffer ensureBuffer(java.nio.FloatBuffer buffer, int size)
          Utility method that returns a buffer with the specified size, or the given buffer if it was non-null and had at least the requested size.
static java.nio.IntBuffer ensureBuffer(java.nio.IntBuffer buffer, int size)
          Utility method that returns a buffer with the specified size, or the given buffer if it was non-null and had at least the requested size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createByteBuffer

public static java.nio.ByteBuffer createByteBuffer(int size)
Create a direct byte buffer with the given size

Parameters:
size - The size of the buffer
Returns:
The buffer

createFloatBuffer

public static java.nio.FloatBuffer createFloatBuffer(int size)
Create a direct float buffer with the given size

Parameters:
size - The size of the buffer
Returns:
The buffer

createIntBuffer

public static java.nio.IntBuffer createIntBuffer(int size)
Create a direct int buffer with the given size

Parameters:
size - The size of the buffer
Returns:
The buffer

createDirectBuffer

public static java.nio.ByteBuffer createDirectBuffer(byte[] a)
Create a direct byte buffer which has the contents of the given array.

Parameters:
a - The array
Returns:
The buffer

createDirectBuffer

public static java.nio.IntBuffer createDirectBuffer(int[] a)
Create a direct int buffer which has the contents of the given array.

Parameters:
a - The array
Returns:
The buffer

createDirectBuffer

public static java.nio.FloatBuffer createDirectBuffer(float[] a)
Create a direct float buffer which has the contents of the given array.

Parameters:
a - The array
Returns:
The buffer

ensureBuffer

public static java.nio.IntBuffer ensureBuffer(java.nio.IntBuffer buffer,
                                              int size)
Utility method that returns a buffer with the specified size, or the given buffer if it was non-null and had at least the requested size.

Parameters:
buffer - The buffer
size - The size
Returns:
The resulting buffer

ensureBuffer

public static java.nio.FloatBuffer ensureBuffer(java.nio.FloatBuffer buffer,
                                                int size)
Utility method that returns a buffer with the specified size, or the given buffer if it was non-null and had at least the requested size.

Parameters:
buffer - The buffer
size - The size
Returns:
The resulting buffer