com.jogamp.opengl.util
Class GLBuffers
java.lang.Object
com.jogamp.common.nio.Buffers
com.jogamp.opengl.util.GLBuffers
public class GLBuffers
- extends Buffers
Utility routines for dealing with direct buffers.
- Author:
- Kenneth Russel, et.al.
Method Summary |
static float[] |
getFloatArray(double[] source)
|
static int |
getNextPowerOf2(int number)
|
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, slice2Float |
GLBuffers
public GLBuffers()
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,
GL_HILO16_NV, GL_SIGNED_HILO16_NV (27)
- 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,
GL_HILO16_NV, GL_SIGNED_HILO16_NV (27)
- 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,
GL_HILO16_NV, GL_SIGNED_HILO16_NV (27)
- 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 objecttmp
- a pass through integer array of size >= 1 used to store temp data (performance)bytesPerElement
- bytes per elementwidth
- in pixelsheight
- in pixelsdepth
- in pixelspack
- 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 objecttmp
- 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, GL_HILO_NV, GL_SIGNED_HILO_NV (26)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,
GL_HILO16_NV, GL_SIGNED_HILO16_NV (28)width
- in pixelsheight
- in pixelsdepth
- in pixelspack
- 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.
getNextPowerOf2
public static final int getNextPowerOf2(int number)
getFloatArray
public static final float[] getFloatArray(double[] source)
Copyright 2010 JogAmp Community.