com.jogamp.opengl.util
Class GLBuffers

java.lang.Object
  extended by com.jogamp.common.nio.Buffers
      extended by com.jogamp.opengl.util.GLBuffers

public class GLBuffers
extends com.jogamp.common.nio.Buffers

Utility routines for dealing with direct buffers.

Author:
Kenneth Russel, Sven Gothel, Michael Bien

Field Summary
 
Fields inherited from class com.jogamp.common.nio.Buffers
SIZEOF_BYTE, SIZEOF_CHAR, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_SHORT
 
Constructor Summary
GLBuffers()
           
 
Method Summary
static float[] getFloatArray(double[] source)
           
static Buffer newDirectGLBuffer(int glType, int numElements)
           
static int sizeof(GL gl, int[] tmp, int bytesPerElement, int width, int height, int depth, boolean pack)
          Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pixel storage state and the given parameters.
static int sizeof(GL gl, int[] tmp, int format, int type, int width, int height, int depth, boolean pack)
          Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pixel storage state and the given parameters.
static int sizeOfGLType(int glType)
           
static Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType)
           
 
Methods inherited from class com.jogamp.common.nio.Buffers
copyByteBuffer, copyFloatBuffer, copyFloatBufferAsByteBuffer, copyIntBuffer, copyIntBufferAsByteBuffer, copyShortBuffer, copyShortBufferAsByteBuffer, getArray, getDirectBufferByteOffset, getDoubleArray, getDoubleBuffer, getFloatArray, getFloatBuffer, getIndirectBufferByteOffset, isDirect, nativeOrder, newDirectByteBuffer, newDirectByteBuffer, newDirectByteBuffer, newDirectByteBuffer, newDirectCharBuffer, newDirectCharBuffer, newDirectCharBuffer, newDirectCharBuffer, newDirectDoubleBuffer, newDirectDoubleBuffer, newDirectDoubleBuffer, newDirectDoubleBuffer, newDirectFloatBuffer, newDirectFloatBuffer, newDirectFloatBuffer, newDirectFloatBuffer, newDirectIntBuffer, newDirectIntBuffer, newDirectIntBuffer, newDirectIntBuffer, newDirectLongBuffer, newDirectLongBuffer, newDirectLongBuffer, newDirectLongBuffer, newDirectShortBuffer, newDirectShortBuffer, newDirectShortBuffer, newDirectShortBuffer, put, putb, putd, putf, puti, puts, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheckBytes, sizeOfBufferElem, slice, slice
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLBuffers

public GLBuffers()
Method Detail

sizeOfGLType

public static final int sizeOfGLType(int glType)
Parameters:
glType - shall be one of GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)
Returns:
-1 if glType is unhandled, otherwise the actual value > 0

newDirectGLBuffer

public static final Buffer newDirectGLBuffer(int glType,
                                             int numElements)
Parameters:
glType - shall be one of GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)
Returns:
null if glType is unhandled, otherwise the new Buffer object

sliceGLBuffer

public static final Buffer sliceGLBuffer(ByteBuffer parent,
                                         int bytePos,
                                         int byteLen,
                                         int glType)
Parameters:
glType - shall be one of GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)
Returns:
null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object

sizeof

public static final int sizeof(GL gl,
                               int[] tmp,
                               int bytesPerElement,
                               int width,
                               int height,
                               int depth,
                               boolean pack)
Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pixel storage state and the given parameters.

This method is security critical, hence it throws an exception (fail-fast) in case of an invalid alignment. In case we forgot to handle proper values, please contact the maintainer.

Parameters:
gl - the current GL object
tmp - a pass through integer array of size >= 1 used to store temp data (performance)
bytesPerElement - bytes per element
width - in pixels
height - in pixels
depth - in pixels
pack - true for read mode GPU -> CPU (pack), otherwise false for write mode CPU -> GPU (unpack)
Returns:
required minimum size of the buffer in bytes
Throws:
GLException - if alignment is invalid. Please contact the maintainer if this is our bug.

sizeof

public static final int sizeof(GL gl,
                               int[] tmp,
                               int format,
                               int type,
                               int width,
                               int height,
                               int depth,
                               boolean pack)
                        throws GLException
Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pixel storage state and the given parameters.

This method is security critical, hence it throws an exception (fail-fast) in case either the format, type or alignment is unhandled. In case we forgot to handle proper values, please contact the maintainer.

Parameters:
gl - the current GL object
tmp - a pass through integer array of size >= 1 used to store temp data (performance)
format - must be one of GL_COLOR_INDEX, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_LUMINANCE, GL_RG, GL_LUMINANCE_ALPHA, GL_RGB, GL_BGR, GL_RGBA, GL_BGRA, GL_ABGR_EXT, GL_RED_INTEGER, GL_GREEN_INTEGER, GL_BLUE_INTEGER, GL_RG_INTEGER, GL_RGB_INTEGER, GL_BGR_INTEGER, GL_RGBA_INTEGER, GL_BGRA_INTEGER (24)
type - must be one of GL_BITMAP, GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (26)
width - in pixels
height - in pixels
depth - in pixels
pack - true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU
Returns:
required minimum size of the buffer in bytes
Throws:
GLException - if format, type or alignment is not handled. Please contact the maintainer if this is our bug.

getFloatArray

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


Copyright 2010 JogAmp Community.