Class GLBuffers
- Author:
- Kenneth Russel, et.al.
-
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic final int
bytesPerPixel
(int format, int type) Returns the number of bytes required for one pixel with the the given OpenGL format and type.static final int
componentCount
(int format) Returns the number of components required for the given OpenGL format.static final float[]
getFloatArray
(double[] source) static final int
getNextPowerOf2
(int number) static final boolean
isGLTypeFixedPoint
(int glType) static final boolean
isSignedGLType
(int glType) static final Buffer
newDirectGLBuffer
(int glType, int numElements) static final int
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 final int
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 final int
sizeOfGLType
(int glType) static final 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, putNb, putNf, putNi, putNs, puts, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheck, rangeCheckBytes, remainingBytes, remainingElem, sizeOfBufferElem, slice, slice, slice2Float, slice2Float, toString
-
Constructor Details
-
GLBuffers
public GLBuffers()
-
-
Method Details
-
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
- 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
- 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
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
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)
-