com.sun.opengl.util
Class BufferUtil

java.lang.Object
  extended by com.sun.opengl.util.BufferUtil

public class BufferUtil
extends Object

Utility routines for dealing with direct buffers.


Field Summary
static int SIZEOF_BYTE
           
static int SIZEOF_DOUBLE
           
static int SIZEOF_FLOAT
           
static int SIZEOF_INT
           
static int SIZEOF_LONG
           
static int SIZEOF_SHORT
           
 
Method Summary
static ByteBuffer copyByteBuffer(ByteBuffer orig)
          Copies the remaining elements (as defined by limit() - position()) in the passed ByteBuffer into a newly-allocated direct ByteBuffer.
static FloatBuffer copyFloatBuffer(FloatBuffer orig)
          Copies the remaining elements (as defined by limit() - position()) in the passed FloatBuffer into a newly-allocated direct FloatBuffer.
static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig)
          Copies the remaining elements (as defined by limit() - position()) in the passed FloatBuffer into a newly-allocated direct ByteBuffer.
static IntBuffer copyIntBuffer(IntBuffer orig)
          Copies the remaining elements (as defined by limit() - position()) in the passed IntBuffer into a newly-allocated direct IntBuffer.
static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig)
          Copies the remaining elements (as defined by limit() - position()) in the passed IntBuffer into a newly-allocated direct ByteBuffer.
static ShortBuffer copyShortBuffer(ShortBuffer orig)
          Copies the remaining elements (as defined by limit() - position()) in the passed ShortBuffer into a newly-allocated direct ShortBuffer.
static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig)
          Copies the remaining elements (as defined by limit() - position()) in the passed ShortBuffer into a newly-allocated direct ByteBuffer.
static float[] getFloatArray(double[] source)
           
static FloatBuffer getFloatBuffer(DoubleBuffer source)
           
static ByteBuffer nativeOrder(ByteBuffer buf)
           
static ByteBuffer newByteBuffer(byte[] values)
           
static ByteBuffer newByteBuffer(byte[] values, int offset)
           
static ByteBuffer newByteBuffer(byte[] values, int offset, int len)
           
static ByteBuffer newByteBuffer(int numElements)
          Allocates a new direct ByteBuffer with the specified number of elements.
static DoubleBuffer newDoubleBuffer(double[] values)
           
static DoubleBuffer newDoubleBuffer(double[] values, int offset)
           
static DoubleBuffer newDoubleBuffer(int numElements)
          Allocates a new direct DoubleBuffer with the specified number of elements.
static FloatBuffer newFloatBuffer(float[] values)
           
static FloatBuffer newFloatBuffer(float[] values, int offset)
           
static FloatBuffer newFloatBuffer(float[] values, int offset, int len)
           
static FloatBuffer newFloatBuffer(int numElements)
          Allocates a new direct FloatBuffer with the specified number of elements.
static Buffer newGLBuffer(int glType, int numElements)
           
static IntBuffer newIntBuffer(int numElements)
          Allocates a new direct IntBuffer with the specified number of elements.
static IntBuffer newIntBuffer(int[] values)
           
static IntBuffer newIntBuffer(int[] values, int offset)
           
static IntBuffer newIntBuffer(int[] values, int offset, int len)
           
static LongBuffer newLongBuffer(int numElements)
          Allocates a new direct LongBuffer with the specified number of elements.
static ShortBuffer newShortBuffer(int numElements)
          Allocates a new direct ShortBuffer with the specified number of elements.
static ShortBuffer newShortBuffer(short[] values)
           
static ShortBuffer newShortBuffer(short[] values, int offset)
           
static ShortBuffer newShortBuffer(short[] values, int offset, int len)
           
static void put(Buffer dest, Buffer v)
           
static void putb(Buffer dest, byte v)
           
static void putd(Buffer dest, double v)
           
static void putf(Buffer dest, float v)
           
static void puti(Buffer dest, int v)
           
static void puts(Buffer dest, short v)
           
static void putx(Buffer dest, int v)
           
static int sizeOfBufferElem(Buffer buffer)
           
static int sizeOfGLType(int glType)
           
static Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZEOF_BYTE

public static final int SIZEOF_BYTE
See Also:
Constant Field Values

SIZEOF_SHORT

public static final int SIZEOF_SHORT
See Also:
Constant Field Values

SIZEOF_INT

public static final int SIZEOF_INT
See Also:
Constant Field Values

SIZEOF_FLOAT

public static final int SIZEOF_FLOAT
See Also:
Constant Field Values

SIZEOF_LONG

public static final int SIZEOF_LONG
See Also:
Constant Field Values

SIZEOF_DOUBLE

public static final int SIZEOF_DOUBLE
See Also:
Constant Field Values
Method Detail

sizeOfGLType

public static final int sizeOfGLType(int glType)

sizeOfBufferElem

public static final int sizeOfBufferElem(Buffer buffer)

newGLBuffer

public static final Buffer newGLBuffer(int glType,
                                       int numElements)

sliceGLBuffer

public static final Buffer sliceGLBuffer(ByteBuffer parent,
                                         int bytePos,
                                         int byteLen,
                                         int glType)

newByteBuffer

public static ByteBuffer newByteBuffer(int numElements)
Allocates a new direct ByteBuffer with the specified number of elements. The returned buffer will have its byte order set to the host platform's native byte order.


newByteBuffer

public static ByteBuffer newByteBuffer(byte[] values,
                                       int offset,
                                       int len)

newByteBuffer

public static ByteBuffer newByteBuffer(byte[] values,
                                       int offset)

newByteBuffer

public static ByteBuffer newByteBuffer(byte[] values)

newDoubleBuffer

public static DoubleBuffer newDoubleBuffer(int numElements)
Allocates a new direct DoubleBuffer with the specified number of elements. The returned buffer will have its byte order set to the host platform's native byte order.


newDoubleBuffer

public static DoubleBuffer newDoubleBuffer(double[] values,
                                           int offset)

newDoubleBuffer

public static DoubleBuffer newDoubleBuffer(double[] values)

newFloatBuffer

public static FloatBuffer newFloatBuffer(int numElements)
Allocates a new direct FloatBuffer with the specified number of elements. The returned buffer will have its byte order set to the host platform's native byte order.


newFloatBuffer

public static FloatBuffer newFloatBuffer(float[] values,
                                         int offset,
                                         int len)

newFloatBuffer

public static FloatBuffer newFloatBuffer(float[] values,
                                         int offset)

newFloatBuffer

public static FloatBuffer newFloatBuffer(float[] values)

newIntBuffer

public static IntBuffer newIntBuffer(int numElements)
Allocates a new direct IntBuffer with the specified number of elements. The returned buffer will have its byte order set to the host platform's native byte order.


newIntBuffer

public static IntBuffer newIntBuffer(int[] values,
                                     int offset,
                                     int len)

newIntBuffer

public static IntBuffer newIntBuffer(int[] values,
                                     int offset)

newIntBuffer

public static IntBuffer newIntBuffer(int[] values)

newLongBuffer

public static LongBuffer newLongBuffer(int numElements)
Allocates a new direct LongBuffer with the specified number of elements. The returned buffer will have its byte order set to the host platform's native byte order.


newShortBuffer

public static ShortBuffer newShortBuffer(int numElements)
Allocates a new direct ShortBuffer with the specified number of elements. The returned buffer will have its byte order set to the host platform's native byte order.


newShortBuffer

public static ShortBuffer newShortBuffer(short[] values,
                                         int offset,
                                         int len)

newShortBuffer

public static ShortBuffer newShortBuffer(short[] values,
                                         int offset)

newShortBuffer

public static ShortBuffer newShortBuffer(short[] values)

copyByteBuffer

public static ByteBuffer copyByteBuffer(ByteBuffer orig)
Copies the remaining elements (as defined by limit() - position()) in the passed ByteBuffer into a newly-allocated direct ByteBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged (though its mark is changed).


copyFloatBuffer

public static FloatBuffer copyFloatBuffer(FloatBuffer orig)
Copies the remaining elements (as defined by limit() - position()) in the passed FloatBuffer into a newly-allocated direct FloatBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged (though its mark is changed).


copyIntBuffer

public static IntBuffer copyIntBuffer(IntBuffer orig)
Copies the remaining elements (as defined by limit() - position()) in the passed IntBuffer into a newly-allocated direct IntBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged (though its mark is changed).


copyShortBuffer

public static ShortBuffer copyShortBuffer(ShortBuffer orig)
Copies the remaining elements (as defined by limit() - position()) in the passed ShortBuffer into a newly-allocated direct ShortBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged (though its mark is changed).


copyFloatBufferAsByteBuffer

public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig)
Copies the remaining elements (as defined by limit() - position()) in the passed FloatBuffer into a newly-allocated direct ByteBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged (though its mark is changed).


copyIntBufferAsByteBuffer

public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig)
Copies the remaining elements (as defined by limit() - position()) in the passed IntBuffer into a newly-allocated direct ByteBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged (though its mark is changed).


copyShortBufferAsByteBuffer

public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig)
Copies the remaining elements (as defined by limit() - position()) in the passed ShortBuffer into a newly-allocated direct ByteBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged (though its mark is changed).


getFloatArray

public static final float[] getFloatArray(double[] source)

getFloatBuffer

public static final FloatBuffer getFloatBuffer(DoubleBuffer source)

nativeOrder

public static ByteBuffer nativeOrder(ByteBuffer buf)

put

public static void put(Buffer dest,
                       Buffer v)

putb

public static void putb(Buffer dest,
                        byte v)

puts

public static void puts(Buffer dest,
                        short v)

puti

public static void puti(Buffer dest,
                        int v)

putx

public static void putx(Buffer dest,
                        int v)

putf

public static void putf(Buffer dest,
                        float v)

putd

public static void putd(Buffer dest,
                        double v)


Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.