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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.jogamp.common.nio.Buffers
Buffers.Cleaner
-
-
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
Constructors Constructor Description GLBuffers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
bytesPerPixel(int format, int type)
Returns the number of bytes required for one pixel with the the given OpenGL format and type.static int
componentCount(int format)
Returns the number of components required for the given OpenGL format.static float[]
getFloatArray(double[] source)
static int
getNextPowerOf2(int number)
static boolean
isGLTypeFixedPoint(int glType)
static boolean
isSignedGLType(int glType)
static Buffer
newDirectGLBuffer(int glType, int numElements)
static int
sizeof(GL gl, int[] tmp, int bytesPerPixel, 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, copyNativeToDirectByteBuffer, 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, put3b, put3d, put3f, put3i, put3s, put4b, put4d, put4f, put4i, put4s, putb, putb, putd, putd, putf, putf, puti, puti, putNb, putNf, putNi, putNs, puts, puts, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheckBytes, remainingBytes, remainingElem, sizeOfBufferElem, sizeOfBufferElem, slice, slice, slice2Char, slice2Char, slice2Double, slice2Double, slice2Float, slice2Float, slice2Int, slice2Int, slice2Long, slice2Long, slice2Short, slice2Short, strnlen, toString, typeNameToBufferClass
-
-
-
-
Method Detail
-
isSignedGLType
public static final boolean isSignedGLType(int glType)
- Parameters:
glType
- GL primitive type- Returns:
- false if one of GL primitive unsigned types, otherwise true
GL_UNSIGNED_BYTE,
GL_UNSIGNED_SHORT,
GL_UNSIGNED_INT,
GL_HILO16_NV
-
isGLTypeFixedPoint
public static final boolean isGLTypeFixedPoint(int glType)
- Parameters:
glType
- GL primitive type- Returns:
- false if one of GL primitive floating point types, otherwise true
GL_FLOAT,
GL_HALF_FLOAT,
GL_HALF_FLOAT_OES,
GL_DOUBLE
-
sizeOfGLType
public static final int sizeOfGLType(int glType)
- Parameters:
glType
- shall be one of (31)
GL_BYTE, GL_UNSIGNED_BYTE,
GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
GL_SHORT, GL_UNSIGNED_SHORT,
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_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
GL.GL_HALF_FLOAT, GLES2.GL_HALF_FLOAT_OES:
GL_FIXED, GL_INT
GL_UNSIGNED_INT, 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_HILO16_NV, GL_SIGNED_HILO16_NV
GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV
GL_FLOAT, GL_DOUBLE- 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 (31)
GL_BYTE, GL_UNSIGNED_BYTE,
GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
GL_SHORT, GL_UNSIGNED_SHORT,
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_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
GL_HALF_FLOAT, GL_HALF_FLOAT_OES
GL_FIXED, GL_INT
GL_UNSIGNED_INT, 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_HILO16_NV, GL_SIGNED_HILO16_NV
GL_FLOAT_32_UNSIGNED_INT_24_8_REV
GL_FLOAT, GL_DOUBLE- 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 (31)
GL_BYTE, GL_UNSIGNED_BYTE,
GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
GL_SHORT, GL_UNSIGNED_SHORT,
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_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
GL_HALF_FLOAT, GL_HALF_FLOAT_OES
GL_FIXED, GL_INT
GL_UNSIGNED_INT, 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_HILO16_NV, GL_SIGNED_HILO16_NV
GL_FLOAT_32_UNSIGNED_INT_24_8_REV
GL_FLOAT, GL_DOUBLE- 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 bytesPerPixel, 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)bytesPerPixel
- bytes per pixel, i.e. viabytesPerPixel(int, int)
.width
- 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 (27)
GL_COLOR_INDEX GL_STENCIL_INDEX
GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
GL_RED GL_RED_INTEGER
GL_GREEN GL_GREEN_INTEGER
GL_BLUE GL_BLUE_INTEGER
GL_ALPHA GL_LUMINANCE (12)
GL_LUMINANCE_ALPHA GL_RG
GL_RG_INTEGER GL_HILO_NV
GL_SIGNED_HILO_NV (5)
GL_YCBCR_422_APPLE
GL_RGB GL_RGB_INTEGER
GL_BGR GL_BGR_INTEGER (4)
GL_RGBA GL_RGBA_INTEGER
GL_BGRA GL_BGRA_INTEGER
GL_ABGR_EXT (5)type
- must be one of (32)
GL_BITMAP,
GL_BYTE, GL_UNSIGNED_BYTE,
GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
GL_SHORT, GL_UNSIGNED_SHORT,
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_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
GL_HALF_FLOAT, GL_HALF_FLOAT_OES
GL_FIXED, GL_INT
GL_UNSIGNED_INT, 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_HILO16_NV, GL_SIGNED_HILO16_NV
GL_FLOAT_32_UNSIGNED_INT_24_8_REV
GL_FLOAT, GL_DOUBLEwidth
- 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.
-
bytesPerPixel
public static final int bytesPerPixel(int format, int type) throws GLException
Returns the number of bytes required for one pixel with the the given OpenGL format and type.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.
See
componentCount(int)
.- Parameters:
format
- must be one of (27)
GL_COLOR_INDEX GL_STENCIL_INDEX
GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
GL_RED GL_RED_INTEGER
GL_GREEN GL_GREEN_INTEGER
GL_BLUE GL_BLUE_INTEGER
GL_ALPHA GL_LUMINANCE (12)
GL_LUMINANCE_ALPHA GL_RG
GL_RG_INTEGER GL_HILO_NV
GL_SIGNED_HILO_NV (5)
GL_YCBCR_422_APPLE
GL_RGB GL_RGB_INTEGER
GL_BGR GL_BGR_INTEGER (4)
GL_RGBA GL_RGBA_INTEGER
GL_BGRA GL_BGRA_INTEGER
GL_ABGR_EXT (5)type
- must be one of (32)
GL_BITMAP,
GL_BYTE, GL_UNSIGNED_BYTE,
GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
GL_SHORT, GL_UNSIGNED_SHORT,
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_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
GL_HALF_FLOAT, GL_HALF_FLOAT_OES
GL_FIXED, GL_INT
GL_UNSIGNED_INT, 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_HILO16_NV, GL_SIGNED_HILO16_NV
GL_FLOAT_32_UNSIGNED_INT_24_8_REV
GL_FLOAT, GL_DOUBLE- Returns:
- required size of one pixel in bytes
- Throws:
GLException
- if format or type alignment is not handled. Please contact the maintainer if this is our bug.
-
componentCount
public static final int componentCount(int format) throws GLException
Returns the number of components required for the given OpenGL format.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:
format
- must be one of (27)
GL_COLOR_INDEX GL_STENCIL_INDEX
GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
GL_RED GL_RED_INTEGER
GL_GREEN GL_GREEN_INTEGER
GL_BLUE GL_BLUE_INTEGER
GL_ALPHA GL_LUMINANCE (12)
GL_LUMINANCE_ALPHA GL_RG
GL_RG_INTEGER GL_HILO_NV
GL_SIGNED_HILO_NV (5)
GL_YCBCR_422_APPLE
GL_RGB GL_RGB_INTEGER
GL_BGR GL_BGR_INTEGER (4)
GL_RGBA GL_RGBA_INTEGER
GL_BGRA GL_BGRA_INTEGER
GL_ABGR_EXT (5)- Returns:
- number of components required for the given OpenGL format
- Throws:
GLException
- if format 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)
-
-