39package com.jogamp.opengl.util;
41import java.nio.Buffer;
42import java.nio.ByteBuffer;
44import com.jogamp.opengl.GL;
45import com.jogamp.opengl.GL2;
46import com.jogamp.opengl.GL2ES2;
47import com.jogamp.opengl.GL2ES3;
48import com.jogamp.opengl.GL2GL3;
49import com.jogamp.opengl.GLContext;
50import com.jogamp.opengl.GLES2;
51import com.jogamp.opengl.GLException;
53import com.jogamp.common.nio.Buffers;
172 return SIZEOF_DOUBLE;
208 return newDirectByteBuffer(numElements);
222 return newDirectShortBuffer(numElements);
236 return newDirectIntBuffer(numElements);
239 return newDirectLongBuffer(numElements);
242 return newDirectFloatBuffer(numElements);
245 return newDirectDoubleBuffer(numElements);
274 public static final Buffer
sliceGLBuffer(
final ByteBuffer parent,
final int bytePos,
final int byteLen,
final int glType) {
275 if (parent ==
null || byteLen == 0) {
278 final int parentPos = parent.position();
279 final int parentLimit = parent.limit();
281 parent.position(bytePos);
282 parent.limit(bytePos + byteLen);
290 res = parent.slice().order(parent.order());
305 res = parent.slice().order(parent.order()).asShortBuffer();
320 res = parent.slice().order(parent.order()).asIntBuffer();
324 res = parent.slice().order(parent.order()).asLongBuffer();
328 res = parent.slice().order(parent.order()).asFloatBuffer();
332 res = parent.slice().order(parent.order()).asDoubleBuffer();
335 parent.position(parentPos).limit(parentLimit);
339 private static final int glGetInteger(
final GL gl,
final int pname,
final int[] tmp) {
364 public static final int sizeof(
final GL gl,
final int tmp[],
366 final boolean pack) {
403 width = Math.max(0, width );
404 height = Math.max(1, height);
405 depth = Math.max(1, depth );
406 skipRows = Math.max(0, skipRows);
407 skipPixels = Math.max(0, skipPixels);
408 alignment = Math.max(1, alignment);
409 skipImages = Math.max(0, skipImages);
411 imageHeight = ( imageHeight > 0 ) ? imageHeight : height;
412 rowLength = ( rowLength > 0 ) ? rowLength : width;
424 int remainder = rowLengthInBytes & ( alignment - 1 );
426 rowLengthInBytes += alignment - remainder;
428 remainder = skipBytes & ( alignment - 1 );
430 skipBytes += alignment - remainder;
435 throw new GLException(
"Invalid alignment "+alignment+
", must be 2**n (1,2,4,8). Pls notify the maintainer in case this is our bug.");
450 ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes +
451 ( skipRows + height - 1 ) * rowLengthInBytes +
520 public static final int sizeof(
final GL gl,
final int tmp[],
521 final int format,
final int type,
final int width,
final int height,
final int depth,
523 if (width < 0)
return 0;
524 if (height < 0)
return 0;
525 if (depth < 0)
return 0;
597 throw new GLException(
"BITMAP type only supported for format COLOR_INDEX and STENCIL_INDEX, not 0x"+Integer.toHexString(format));
657 throw new GLException(
"type 0x"+Integer.toHexString(type)+
"/"+
"format 0x"+Integer.toHexString(format)+
" not supported [yet], pls notify the maintainer in case this is our bug.");
659 return compCount * compSize;
739 throw new GLException(
"format 0x"+Integer.toHexString(format)+
" not supported [yet], pls notify the maintainer in case this is our bug.");
745 if (((number-1) & number) == 0) {
761 int i = source.length;
762 final float[] dest =
new float[i--];
764 dest[i] = (float) source[i];
Abstraction for an OpenGL rendering context.
static final VersionNumber Version1_2
Version 1.2, i.e.
final VersionNumber getGLVersionNumber()
Returns this context OpenGL version.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Utility routines for dealing with direct buffers.
static final int componentCount(final int format)
Returns the number of components required for the given OpenGL format.
static final Buffer sliceGLBuffer(final ByteBuffer parent, final int bytePos, final int byteLen, final int glType)
static final boolean isSignedGLType(final int glType)
static final int sizeof(final GL gl, final int tmp[], final int bytesPerPixel, int width, int height, int depth, final boolean pack)
Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pi...
static final boolean isGLTypeFixedPoint(final int glType)
static final int sizeof(final GL gl, final int tmp[], final int format, final int type, final int width, final int height, final int depth, final boolean pack)
Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pi...
static final int bytesPerPixel(final int format, final int type)
Returns the number of bytes required for one pixel with the the given OpenGL format and type.
static final int sizeOfGLType(final int glType)
static final int getNextPowerOf2(int number)
static final float[] getFloatArray(final double[] source)
static final Buffer newDirectGLBuffer(final int glType, final int numElements)
static final int GL_UNPACK_ROW_LENGTH
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_EXT_unpack_subimage Alias for: GL_UNPACK_ROW_LE...
static final int GL_UNPACK_SKIP_PIXELS
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_EXT_unpack_subimage Alias for: GL_UNPACK_SKIP_P...
static final int GL_RED
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_NV_blend_equation_advanced, GL_EXT_texture_rg A...
static final int GL_UNSIGNED_INT_2_10_10_10_REV
GL_ES_VERSION_3_0, GL_VERSION_1_2, GL_EXT_texture_type_2_10_10_10_REV Alias for: GL_UNSIGNED_INT_2_10...
static final int GL_STENCIL_INDEX
Part of GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0
static final int GL_INT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_INT" with expression '0x1404',...
static final int GL_RG
GL_ES_VERSION_3_0, GL_ARB_texture_rg, GL_VERSION_3_0, GL_EXT_texture_rg Alias for: GL_RG_EXT Define ...
static final int GL_UNPACK_SKIP_ROWS
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_EXT_unpack_subimage Alias for: GL_UNPACK_SKIP_R...
static final int GL_DEPTH_COMPONENT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_DEPTH_COMPONENT" with expression '0x1902...
static final int GL_UNSIGNED_INT_10_10_10_2
GL_VERSION_1_2, GL_EXT_packed_pixels, GL_OES_vertex_type_10_10_10_2 Alias for: GL_UNSIGNED_INT_10_10_...
static final int GL_GREEN
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_NV_blend_equation_advanced Alias for: GL_GREEN_...
static final int GL_PACK_SKIP_PIXELS
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_PACK_SKIP_PIXELS" with expression '0x0D0...
static final int GL_FLOAT_32_UNSIGNED_INT_24_8_REV
GL_ARB_depth_buffer_float, GL_ES_VERSION_3_0, GL_VERSION_3_0, GL_NV_depth_buffer_float Alias for: GL_...
static final int GL_BLUE
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_NV_blend_equation_advanced Alias for: GL_BLUE_N...
static final int GL_RGBA_INTEGER
GL_ES_VERSION_3_0, GL_VERSION_3_0, GL_EXT_texture_integer Alias for: GL_RGBA_INTEGER_EXT Define "GL_...
static final int GL_UNPACK_SKIP_IMAGES
GL_ES_VERSION_3_0, GL_VERSION_1_2, GL_EXT_texture3D Alias for: GL_UNPACK_SKIP_IMAGES_EXT Define "GL_...
static final int GL_RG_INTEGER
GL_ES_VERSION_3_0, GL_ARB_texture_rg, GL_VERSION_3_0 Define "GL_RG_INTEGER" with expression '0x8228',...
static final int GL_RED_INTEGER
GL_ES_VERSION_3_0, GL_VERSION_3_0, GL_EXT_texture_integer Alias for: GL_RED_INTEGER_EXT Define "GL_R...
static final int GL_UNSIGNED_INT_5_9_9_9_REV
GL_ES_VERSION_3_0, GL_VERSION_3_0, GL_EXT_texture_shared_exponent, GL_APPLE_texture_packed_float Alia...
static final int GL_PACK_SKIP_ROWS
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_PACK_SKIP_ROWS" with expression '0x0D03'...
static final int GL_UNPACK_IMAGE_HEIGHT
GL_ES_VERSION_3_0, GL_VERSION_1_2, GL_EXT_texture3D Alias for: GL_UNPACK_IMAGE_HEIGHT_EXT Define "GL...
static final int GL_PACK_ROW_LENGTH
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_PACK_ROW_LENGTH" with expression '0x0D02...
static final int GL_RGB_INTEGER
GL_ES_VERSION_3_0, GL_VERSION_3_0, GL_EXT_texture_integer Alias for: GL_RGB_INTEGER_EXT Define "GL_R...
static final int GL_PACK_IMAGE_HEIGHT
GL_VERSION_1_2, GL_EXT_texture3D Alias for: GL_PACK_IMAGE_HEIGHT_EXT Define "GL_PACK_IMAGE_HEIGHT" w...
static final int GL_UNSIGNED_SHORT_5_6_5_REV
GL_VERSION_1_2 Define "GL_UNSIGNED_SHORT_5_6_5_REV" with expression '0x8364', CType: int
static final int GL_UNSIGNED_INT_8_8_8_8
GL_VERSION_1_2, GL_EXT_packed_pixels Alias for: GL_UNSIGNED_INT_8_8_8_8_EXT Define "GL_UNSIGNED_INT_...
static final int GL_DOUBLE
GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_DOUBLE" with expression '0x140A', CType: int
static final int GL_UNSIGNED_SHORT_4_4_4_4_REV
GL_VERSION_1_2, GL_EXT_read_format_bgra, GL_IMG_read_format Alias for: GL_UNSIGNED_SHORT_4_4_4_4_REV_...
static final int GL_BGRA_INTEGER
GL_VERSION_3_0, GL_EXT_texture_integer Alias for: GL_BGRA_INTEGER_EXT Define "GL_BGRA_INTEGER" with ...
static final int GL_UNSIGNED_INT_8_8_8_8_REV
GL_VERSION_1_2 Define "GL_UNSIGNED_INT_8_8_8_8_REV" with expression '0x8367', CType: int
static final int GL_UNSIGNED_BYTE_3_3_2
GL_VERSION_1_2, GL_EXT_packed_pixels Alias for: GL_UNSIGNED_BYTE_3_3_2_EXT Define "GL_UNSIGNED_BYTE_...
static final int GL_UNSIGNED_SHORT_1_5_5_5_REV
GL_VERSION_1_2, GL_EXT_read_format_bgra Alias for: GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT Define "GL_UNSI...
static final int GL_PACK_SKIP_IMAGES
GL_VERSION_1_2, GL_EXT_texture3D Alias for: GL_PACK_SKIP_IMAGES_EXT Define "GL_PACK_SKIP_IMAGES" wit...
static final int GL_BLUE_INTEGER
GL_VERSION_3_0, GL_EXT_texture_integer Alias for: GL_BLUE_INTEGER_EXT Define "GL_BLUE_INTEGER" with ...
static final int GL_BGR_INTEGER
GL_VERSION_3_0, GL_EXT_texture_integer Alias for: GL_BGR_INTEGER_EXT Define "GL_BGR_INTEGER" with ex...
static final int GL_GREEN_INTEGER
GL_VERSION_3_0, GL_EXT_texture_integer Alias for: GL_GREEN_INTEGER_EXT Define "GL_GREEN_INTEGER" wit...
static final int GL_UNSIGNED_BYTE_2_3_3_REV
GL_VERSION_1_2 Define "GL_UNSIGNED_BYTE_2_3_3_REV" with expression '0x8362', CType: int
static final int GL_ABGR_EXT
GL_EXT_abgr Define "GL_ABGR_EXT" with expression '0x8000', CType: int
static final int GL_SIGNED_HILO_NV
GL_NV_texture_shader Define "GL_SIGNED_HILO_NV" with expression '0x86F9', CType: int
static final int GL_HILO_NV
GL_NV_texture_shader Define "GL_HILO_NV" with expression '0x86F4', CType: int
static final int GL_UNSIGNED_SHORT_8_8_APPLE
GL_APPLE_ycbcr_422, GL_APPLE_rgb_422 Define "GL_UNSIGNED_SHORT_8_8_APPLE" with expression '0x85BA',...
static final int GL_UNSIGNED_SHORT_8_8_REV_APPLE
GL_APPLE_ycbcr_422, GL_APPLE_rgb_422 Define "GL_UNSIGNED_SHORT_8_8_REV_APPLE" with expression '0x85BB...
static final int GL_YCBCR_422_APPLE
GL_APPLE_ycbcr_422 Define "GL_YCBCR_422_APPLE" with expression '0x85B9', CType: int
static final int GL_COLOR_INDEX
GL_VERSION_1_0 Define "GL_COLOR_INDEX" with expression '0x1900', CType: int
static final int GL_HILO16_NV
GL_NV_texture_shader Define "GL_HILO16_NV" with expression '0x86F8', CType: int
static final int GL_SIGNED_HILO16_NV
GL_NV_texture_shader Define "GL_SIGNED_HILO16_NV" with expression '0x86FA', CType: int
static final int GL_BITMAP
GL_VERSION_1_0 Define "GL_BITMAP" with expression '0x1A00', CType: int
boolean isGL2GL3()
Indicates whether this GL object conforms to a GL2GL3 compatible profile.
boolean isGL3ES3()
Indicates whether this GL object conforms to a GL3ES3 compatible profile.
boolean isGL2ES3()
Indicates whether this GL object conforms to a either a GL2GL3 or GL3ES3 compatible profile.
GLContext getContext()
Returns the GLContext associated which this GL object.
static final int GL_HALF_FLOAT_OES
GL_OES_texture_half_float Define "GL_HALF_FLOAT_OES" with expression '0x8D61', CType: int
static final int GL_UNSIGNED_SHORT_4_4_4_4
GL_ES_VERSION_2_0, GL_VERSION_1_2, GL_VERSION_ES_1_0, GL_EXT_packed_pixels Alias for: GL_UNSIGNED_SHO...
void glGetIntegerv(int pname, IntBuffer data)
Entry point to C language function: void {@native glGetIntegerv}(GLenum pname, GLint * data) Part ...
static final int GL_BGRA
GL_VERSION_1_2, GL_IMG_read_format, GL_APPLE_texture_format_BGRA8888, GL_EXT_texture_format_BGRA8888,...
static final int GL_UNPACK_ALIGNMENT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNPACK_ALIGNMENT" wit...
static final int GL_RGB
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RGB" with expression ...
static final int GL_UNSIGNED_INT_10F_11F_11F_REV
Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_packed_float
static final int GL_FIXED
GL_ARB_ES2_compatibility, GL_ES_VERSION_2_0, GL_VERSION_4_1, GL_VERSION_ES_1_0, GL_OES_fixed_point Al...
static final int GL_LUMINANCE_ALPHA
GL_ES_VERSION_2_0, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_LUMINANCE_ALPHA" with expression '0x1...
static final int GL_DEPTH_STENCIL
GL_ES_VERSION_3_0, GL_ARB_framebuffer_object, GL_VERSION_3_0, GL_OES_packed_depth_stencil,...
static final int GL_SHORT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_SHORT" with expressio...
static final int GL_UNSIGNED_INT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_OES_element_index_uint Define "GL_UNSIGNED_INT"...
static final int GL_FLOAT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FLOAT" with expressio...
static final int GL_LUMINANCE
GL_ES_VERSION_2_0, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_LUMINANCE" with expression '0x1909',...
static final int GL_UNSIGNED_SHORT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_SHORT" with ...
static final int GL_UNSIGNED_SHORT_5_5_5_1
GL_ES_VERSION_2_0, GL_VERSION_1_2, GL_VERSION_ES_1_0, GL_EXT_packed_pixels Alias for: GL_UNSIGNED_SHO...
static final int GL_BGR
GL_VERSION_1_2, GL_EXT_bgra Alias for: GL_BGR_EXT Define "GL_BGR" with expression '0x80E0',...
static final int GL_HALF_FLOAT
Part of GL_ARB_half_float_vertex; GL_NV_half_float; GL_ARB_half_float_pixel, earmarked for ES 3....
static final int GL_ALPHA
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_ALPHA" with expressio...
static final int GL_PACK_ALIGNMENT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_PACK_ALIGNMENT" with ...
static final int GL_UNSIGNED_SHORT_5_6_5
GL_ES_VERSION_2_0, GL_VERSION_1_2, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_SHORT_5_6_5" with expression...
static final int GL_RGBA
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RGBA" with expression...
static final int GL_UNSIGNED_INT_24_8
GL_ES_VERSION_3_0, GL_ARB_framebuffer_object, GL_VERSION_3_0, GL_NV_packed_depth_stencil,...
static final int GL_UNSIGNED_BYTE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_BYTE" with e...
static final int GL_BYTE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_BYTE" with expression...