# This .cfg file provides common options used among all glue code
# generated for Jogl on all platforms.

HierarchicalNativeOutput false

# Raise GLException instead of RuntimeException in glue code
RuntimeExceptionType GLException
UnsupportedExceptionType GLException

# Inform the glue code generator of the association between #defines
# and functions and the extensions in which they are defined
GLHeader GL/gl.h
GLHeader GL/glext.h
GLHeader GL/glcorearb.h
GLHeader GL/glcorearbext.h
GLHeader GLES/gl.h
GLHeader GLES/glext.h
GLHeader GLES2/gl2.h
GLHeader GLES2/gl2ext.h
GLHeader GLES3/gl3.h
GLHeader GLES3/gl3ext.h
GLHeader GL/glext-20130207.h

# Imports needed by all glue code
Import java.util.*
Import javax.media.opengl.*
Import javax.media.opengl.fixedfunc.*
Import jogamp.opengl.*

#####################################################################
# Mostly desktop OpenGL stuff below
#

# Don't output #defines of GL version identifier strings as constants, 
# because we don't need them java-side. 
Ignore GL_VERSION_.+

Ignore KHRONOS_.+

# Ignore GL functions that deal with explicit pointer values in such a
# way that we cannot implement the functionality in Java
Ignore glGetBufferPointerv
Ignore glGetBufferPointervARB
Ignore glGetBufferPointerivNV
Ignore glGetNamedBufferPointervEXT
Ignore glGetPointerv
Ignore glGetPointervEXT
Ignore glGetPointerIndexedvEXT
Ignore glGetTexParameterPointervAPPLE
Ignore glGetVertexAttribPointerv
Ignore glGetVertexAttribPointervARB
Ignore glGetVertexAttribPointervNV
Ignore glTracePointerRangeMESA 
Ignore glDebugMessageCallbackAMD
Ignore glDebugMessageCallbackARB
Ignore glDebugMessageCallbackKHR
Ignore glDebugMessageCallback

# Manually implement glMapBuffer and glMapBufferRange as the size of the returned buffer
# can only be computed by calling another routine
ManuallyImplement glMapBuffer
ForceProcAddressGen glMapBuffer
ManuallyImplement glMapBufferRange
ForceProcAddressGen glMapBufferRange

# Ignore the ATI_map_object_buffer extension for now unless someone
# claims they need it, as it will undoubtedly require a similar
# construct to glMapBuffer
Ignore glMapObjectBufferATI
Ignore glUnmapObjectBufferATI

# Ignore some GL functions that have outgoing void** parameters; we cannot yet deal with them
Ignore glGetVariantPointervEXT

# FIXME: these extensions require either a handle to a device context
# or take void** parameters or both. Until we think through the
# semantics of each of these individually we need to disable them.
# WGL_ARB_buffer_region
Ignore wglCreateBufferRegion
Ignore wglDeleteBufferRegion
Ignore wglSaveBufferRegion
Ignore wglRestoreBufferRegion
Ignore wglGetSyncValuesOML
Ignore wglGetMscRateOML
Ignore wglSwapBuffersMscOML
Ignore wglSwapLayerBuffersMscOML
Ignore wglWaitForMscOML
Ignore wglWaitForSbcOML
Ignore wglGetDigitalVideoParametersI3D
Ignore wglSetDigitalVideoParametersI3D
Ignore wglGetGammaTableParametersI3D
Ignore wglSetGammaTableParametersI3D
Ignore wglGetGammaTableI3D
Ignore wglSetGammaTableI3D
Ignore wglEnableGenlockI3D
Ignore wglDisableGenlockI3D
Ignore wglIsEnabledGenlockI3D
Ignore wglGenlockSourceI3D
Ignore wglGetGenlockSourceI3D
Ignore wglGenlockSourceEdgeI3D
Ignore wglGetGenlockSourceEdgeI3D
Ignore wglGenlockSampleRateI3D
Ignore wglGetGenlockSampleRateI3D
Ignore wglGenlockSourceDelayI3D
Ignore wglGetGenlockSourceDelayI3D
Ignore wglQueryGenlockMaxSourceDelayI3D
Ignore wglCreateImageBufferI3D
Ignore wglDestroyImageBufferI3D
Ignore wglAssociateImageBufferEventsI3D
Ignore wglReleaseImageBufferEventsI3D

#
# IgnoreExtension directives
#

# Ignore extensions requiring persistent pointer-to-pointer storage as
# there is no such thing as a direct "BufferBuffer"
IgnoreExtension GL_IBM_vertex_array_lists
IgnoreExtension GL_INTEL_parallel_arrays
IgnoreExtension GL_SUN_triangle_list

# Ignore extensions never approved by the ARB
IgnoreExtension GL_EXT_coordinate_frame

# Ignore discontinued extensions
IgnoreExtension GL_NV_element_array

# >>> OpenGL 1.1
# Ignore extensions subsumed in OpenGL 1.1 (from OpenGL 1.1 spec, Appendix C)
IgnoreExtension GL_EXT_vertex_array
IgnoreExtension GL_EXT_blend_logic_op
IgnoreExtension GL_EXT_copy_texture
IgnoreExtension GL_EXT_polygon_offset
IgnoreExtension GL_EXT_subtexture
IgnoreExtension GL_EXT_texture
IgnoreExtension GL_EXT_texture_object
# <<< OpenGL 1.1

# >>> OpenGL 1.2
# Ignore extensions subsumed in OpenGL 1.2 and 1.2.1 (from OpenGL 1.2.1 spec, Appendix D)
IgnoreExtension GL_EXT_bgra
IgnoreExtension GL_EXT_blend_color
IgnoreExtension GL_EXT_blend_minmax
IgnoreExtension GL_EXT_blend_subtract
IgnoreExtension GL_EXT_color_subtable
IgnoreExtension GL_EXT_convolution
IgnoreExtension GL_EXT_draw_range_elements
IgnoreExtension GL_EXT_histogram
IgnoreExtension GL_EXT_packed_pixels
# NOTE: also ignoring GL_EXT_paletted_texture because it appears that it was subsumed
# into the core even though that isn't stated explicitly in the spec
IgnoreExtension GL_EXT_paletted_texture
IgnoreExtension GL_EXT_rescale_normal
IgnoreExtension GL_EXT_separate_specular_color
IgnoreExtension GL_EXT_texture3D
IgnoreExtension GL_HP_convolution_border_modes
IgnoreExtension GL_SGI_color_matrix
IgnoreExtension GL_SGI_color_table
IgnoreExtension GL_SGIS_texture_edge_clamp
IgnoreExtension GL_SGIS_texture_lod
# <<< OpenGL 1.2

# >>> OpenGL 1.3
# Ignore extensions subsumed in OpenGL 1.3 (from OpenGL 1.3 spec, Appendix F)
IgnoreExtension GL_ARB_multisample
IgnoreExtension GL_ARB_multitexture
IgnoreExtension GL_ARB_texture_compression
IgnoreExtension GL_ARB_texture_cube_map
IgnoreExtension GL_ARB_texture_border_clamp
IgnoreExtension GL_ARB_texture_env_add
IgnoreExtension GL_ARB_texture_env_combine
IgnoreExtension GL_ARB_texture_env_dot3
IgnoreExtension GL_ARB_transpose_matrix
IgnoreExtension GL_EXT_texture_cube_map
IgnoreExtension GL_EXT_texture_env_add
IgnoreExtension GL_EXT_texture_env_combine
IgnoreExtension GL_EXT_texture_env_dot3
IgnoreExtension GL_SGIS_texture_border_clamp
# <<< OpenGL 1.3

# >>> OpenGL 1.4
# Ignore extensions subsumed in OpenGL 1.4 (from OpenGL 1.4 spec, Appendix G)
IgnoreExtension GL_ARB_depth_texture
IgnoreExtension GL_ARB_point_parameters
IgnoreExtension GL_ARB_shadow
IgnoreExtension GL_ARB_texture_env_crossbar
IgnoreExtension GL_ARB_texture_mirrored_repeat
IgnoreExtension GL_ARB_window_pos
IgnoreExtension GL_EXT_blend_func_separate
IgnoreExtension GL_EXT_fog_coord
IgnoreExtension GL_EXT_texture_lod_bias
IgnoreExtension GL_EXT_multi_draw_arrays
IgnoreExtension GL_EXT_secondary_color
IgnoreExtension GL_EXT_stencil_wrap
IgnoreExtension GL_NV_blend_square
IgnoreExtension GL_SGIS_generate_mipmap
# <<< OpenGL 1.4

# >>> OpenGL 1.5
# Ignore extensions subsumed in OpenGL 1.5 (from OpenGL 1.5 spec, Appendix H)
IgnoreExtension GL_ARB_occlusion_query
IgnoreExtension GL_ARB_vertex_buffer_object
IgnoreExtension GL_EXT_shadow_funcs
# <<< OpenGL 1.5

# >>> OpenGL 2.0
# Ignore extensions subsumed in OpenGL 2.0 (from OpenGL 2.0 spec, Appendix I)
# NOTE that GL_ARB_shader_objects is NOT ignored here, because the
# naming convention is too different for us to pick up the entry
# points automatically (e.g. glCreateShaderObjectARB was exposed as
# glCreateShader)
# IgnoreExtension GL_ARB_shader_objects
IgnoreExtension GL_ARB_vertex_shader
IgnoreExtension GL_ARB_fragment_shader
IgnoreExtension GL_ARB_texture_non_power_of_two
IgnoreExtension GL_ARB_point_sprite
IgnoreExtension GL_ARB_draw_buffers
IgnoreExtension GL_EXT_blend_equation_separate
# Don't ignore the following one since the entry point is different from anything in the core
# IgnoreExtension GL_EXT_stencil_two_side
# <<< OpenGL 2.0

# >>> OpenGL 2.1
# Ignore extensions subsumed in OpenGL 2.1 (from OpenGL 2.1 spec, Appendix J)
IgnoreExtension GL_ARB_pixel_buffer_object
IgnoreExtension GL_EXT_texture_sRGB
# <<< OpenGL 2.1

# >>> OpenGL 3.0
# Ignore/Rename extensions subsumed in OpenGL 3.0 (from OpenGL 3.0 spec, Appendix N)
RenameExtensionIntoCore GL_EXT_gpu_shader4

RenameExtensionIntoCore GL_NV_conditional_render

RenameExtensionIntoCore GL_APPLE_flush_buffer_range

RenameExtensionIntoCore GL_ARB_color_buffer_float
# gl.h uses GL_ARB_depth_buffer_float
RenameExtensionIntoCore GL_ARB_depth_buffer_float
IgnoreExtension GL_NV_depth_buffer_float
RenameExtensionIntoCore GL_ARB_texture_float
RenameExtensionIntoCore GL_EXT_packed_float
RenameExtensionIntoCore GL_EXT_texture_shared_exponent

# gl.h uses GL_ARB_framebuffer_object
RenameExtensionIntoCore GL_ARB_framebuffer_object
IgnoreExtension GL_EXT_framebuffer_object

RenameExtensionIntoCore GL_NV_half_float
RenameExtensionIntoCore GL_ARB_half_float_pixel

# naming collision w/ GL_EXT_multisampled_render_to_texture, but included anyways
# RenameExtensionIntoCore GL_EXT_framebuffer_multisample 
IgnoreExtension GL_EXT_framebuffer_multisample 
RenameExtensionIntoCore GL_EXT_framebuffer_blit

#Big gap of promoted tokens and functions: GL_EXT_texture_integer
RenameExtensionIntoCore GL_EXT_texture_integer

RenameExtensionIntoCore GL_EXT_texture_array

RenameExtensionIntoCore GL_EXT_packed_depth_stencil

RenameExtensionIntoCore GL_EXT_draw_buffers2

# gl.h uses GL_ARB_texture_compression_rgtc
RenameExtensionIntoCore GL_ARB_texture_compression_rgtc
IgnoreExtension GL_EXT_texture_compression_rgtc

IgnoreExtension GL_EXT_transform_feedback
IgnoreExtension GL_NV_transform_feedback

# gl.h uses GL_ARB_vertex_array_object
RenameExtensionIntoCore GL_ARB_vertex_array_object
IgnoreExtension GL_APPLE_vertex_array_object

# gl.h uses GL_ARB_framebuffer_sRGB
RenameExtensionIntoCore GL_ARB_framebuffer_sRGB
IgnoreExtension GL_EXT_framebuffer_sRGB

RenameExtensionIntoCore GL_ARB_map_buffer_range

# <<< OpenGL 3.0

# >>> OpenGL 3.1
# Rename extension suffices (if exist) subsumed in OpenGL 3.1 (from OpenGL 3.1 spec, Appendix G.1)
# We alias 3.1 subsumed extension even for GL2, due to the convenience of the common GL2GL3 profile!
RenameExtensionIntoCore GL_ARB_draw_instanced
IgnoreExtension GL_EXT_draw_instanced
RenameExtensionIntoCore GL_ARB_copy_buffer
# Does not match the common namespace GL_NV_primitive_restart
RenameExtensionIntoCore GL_ARB_texture_buffer_object
IgnoreExtension GL_EXT_texture_buffer_object
# We rename EXT_texture_rectangle into core, so ARB_texture_rectangle will stay for convenience
RenameExtensionIntoCore GL_EXT_texture_rectangle
IgnoreExtension GL_NV_texture_rectangle
RenameExtensionIntoCore GL_ARB_uniform_buffer_object
# Use Manual definition, otherwise GlueGen uses 'long' type
Ignore GL_INVALID_INDEX
# <<< OpenGL 3.1

# >>> OpenGL 3.2
# Rename extension suffices (if exist) subsumed in OpenGL 3.2 (from OpenGL 3.2 spec, Appendix H.1)
RenameExtensionIntoCore GL_ARB_vertex_array_bgra
RenameExtensionIntoCore GL_ARB_draw_elements_base_vertex
RenameExtensionIntoCore GL_ARB_fragment_coord_conventions
RenameExtensionIntoCore GL_ARB_provoking_vertex
RenameExtensionIntoCore GL_ARB_seamless_cube_map
RenameExtensionIntoCore GL_ARB_texture_multisample
RenameExtensionIntoCore GL_ARB_depth_clamp
# GL_ARB_geometry_shader4 is subsumed but values/namespace is orthogonal
IgnoreExtension GL_EXT_geometry_shader4
RenameExtensionIntoCore GL_ARB_sync
# <<< OpenGL 3.2

# >>> OpenGL 3.3
# Rename extension suffices (if exist) subsumed in OpenGL 3.3 (from OpenGL 3.3 spec, Appendix I.1)
RenameExtensionIntoCore GL_ARB_shader_bit_encoding
RenameExtensionIntoCore GL_ARB_blend_func_extended
RenameExtensionIntoCore GL_ARB_explicit_attrib_location
RenameExtensionIntoCore GL_ARB_occlusion_query2
RenameExtensionIntoCore GL_ARB_sampler_objects
RenameExtensionIntoCore GL_ARB_texture_rgb10_a2ui
RenameExtensionIntoCore GL_ARB_texture_swizzle
RenameExtensionIntoCore GL_ARB_timer_query
RenameExtensionIntoCore GL_ARB_instanced_arrays
RenameExtensionIntoCore GL_ARB_vertex_type_2_10_10_10_rev
# <<< OpenGL 3.3

# >>> OpenGL 4.0
# Rename extension suffices (if exist) subsumed in OpenGL 4.0 (from OpenGL 4.0 spec, Appendix J.1)
RenameExtensionIntoCore GL_ARB_texture_query_lod
RenameExtensionIntoCore GL_ARB_draw_buffers_blend
RenameExtensionIntoCore GL_ARB_draw_indirect
RenameExtensionIntoCore GL_ARB_gpu_shader5
RenameExtensionIntoCore GL_ARB_gpu_shader_fp64
RenameExtensionIntoCore GL_ARB_sample_shading
RenameExtensionIntoCore GL_ARB_shader_subroutine
RenameExtensionIntoCore GL_ARB_tessellation_shader
RenameExtensionIntoCore GL_ARB_texture_buffer_object_rgb32
RenameExtensionIntoCore GL_ARB_texture_cube_map_array
RenameExtensionIntoCore GL_ARB_texture_gather
RenameExtensionIntoCore GL_ARB_transform_feedback2
RenameExtensionIntoCore GL_ARB_transform_feedback3
# <<< OpenGL 4.0

# >>> OpenGL 4.1
# Rename extension suffices (if exist) subsumed in OpenGL 4.1 (from OpenGL 4.1 spec, Appendix K.1)
RenameExtensionIntoCore GL_ARB_ES2_compatibility
RenameExtensionIntoCore GL_ARB_get_program_binary
RenameExtensionIntoCore GL_ARB_separate_shader_objects
RenameExtensionIntoCore GL_ARB_shader_precision
RenameExtensionIntoCore GL_ARB_vertex_attrib_64bit
IgnoreExtension GL_EXT_vertex_attrib_64bit
RenameExtensionIntoCore GL_ARB_viewport_array
# <<< OpenGL 4.1

# >>> OpenGL 4.2
# Rename extension suffices (if exist) subsumed in OpenGL 4.2 (from OpenGL 4.2 spec, Appendix L.1)
# <<< OpenGL 4.2

# >>> OpenGL 4.3
# Rename extension suffices (if exist) subsumed in OpenGL 4.3 (from OpenGL 4.3 spec, Appendix ?.1)
RenameExtensionIntoCore GL_ARB_debug_output
# <<< OpenGL 4.3

# >>> OpenGL ES 2.0
# <<< OpenGL ES 2.0

# >>> OpenGL ES 3.0
# <<< OpenGL ES 3.0

# Ignore a few obsolete versions of extensions that have been subsumed into the core or ARB extensions
IgnoreExtension GL_EXT_multisample
IgnoreExtension GL_EXT_point_parameters
IgnoreExtension GL_EXT_separate_shader_objects
IgnoreExtension GL_EXT_shader_image_load_store

#
# Opaques and other directives for platform-independent routines
#

Opaque boolean GLboolean
Opaque long GLsync
Opaque long GLeglImageOES
Opaque long cl_context
Opaque long cl_event
ReturnsString glGetString
ReturnsString glGetStringi

# Experimental: Only NIO function, no arrays ..
# NIOOnly __ALL__

#
# NIODirectOnly directives for pointer functions 
#               essential where memory needs to be kept pinpointed after the function call.
#               essential where the buffer lifecycle extends the function call.
#
# Note-1:       API calls like glColorPointer(..) will not be exploded to 
#               multiple primitive arrays, since the pointer argument is 'void *'.
#
# Note-2:       It may be possible to track the primitive non-direct NIO backed arrays and pinpoint them.
#               JNI's Get*ArrayElements may be able to pinpoint, however it could result
#               in a copy of the data, which would render this feature non performant. 
#               The tracking itself may be another no-go, since it would add up complexity
#               and failing to free resources would be another negative sideeffect.
#
NIODirectOnly glColorPointer
NIODirectOnly glEdgeFlagPointer
NIODirectOnly glFeedbackBuffer
NIODirectOnly glFogCoordPointer
NIODirectOnly glGetBufferSubData
NIODirectOnly glGetProgramStringARB
NIODirectOnly glIndexPointer
NIODirectOnly glMatrixIndexPointerARB
NIODirectOnly glMultiTexCoordPointerEXT
NIODirectOnly glNormalPointer
NIODirectOnly glPixelDataRangeNV
NIODirectOnly glSecondaryColorPointer
NIODirectOnly glSelectBuffer
NIODirectOnly glTangentPointerEXT
NIODirectOnly glTexCoordPointer
NIODirectOnly glVariantPointerEXT
NIODirectOnly glVertexArrayRangeNV
NIODirectOnly glVertexArrayRangeApple
NIODirectOnly glVertexAttribIPointer
NIODirectOnly glVertexAttribLPointer
NIODirectOnly glVertexAttribPointer
NIODirectOnly glVertexPointer
NIODirectOnly glVertexWeightPointerEXT
NIODirectOnly glWeightPointerARB
NIODirectOnly wglFreeMemoryNV
NIODirectOnly glXFreeMemoryNV

# Native PointerBuffer usage:
NIODirectOnly glMultiDrawElements
NIODirectOnly glMultiDrawElementsBaseVertex
NIODirectOnly glVDPAUMapSurfacesNV
NIODirectOnly glVDPAUUnmapSurfacesNV
NIODirectOnly glExtGetBufferPointervQCOM

#NIO Review: No technical reason to constrain array access for these:
#Return values
#NIODirectOnly glGenBuffers
#NIODirectOnly glGetPointerv

#
# NIODirectOnly directives for other extensions
#
#NIO Review: No technical reason to constrain array access for these:

# Capacity of wglAllocateMemoryNV/glXAllocateMemoryNV return value is
# same as value of first argument
ReturnValueCapacity wglAllocateMemoryNV {0}
ReturnValueCapacity glXAllocateMemoryNV {0}

# Pass arguments to ARB_vertex_program, ARB_fragment_program,
# ARB_shader_objects, NV_vertex_program, NV_fragment_program, and
# ARB_vertex_shader as Strings
ArgumentIsString glBindAttribLocation 2
ArgumentIsString glBindAttribLocationARB 2
ArgumentIsString glGetAttribLocation 1
ArgumentIsString glGetAttribLocationARB 1
ArgumentIsString glGetProgramNamedParameterfvNV 2
ArgumentIsString glGetProgramNamedParameterdvNV 2
ArgumentIsString glGetUniformLocation 1
ArgumentIsString glGetUniformLocationARB 1
ArgumentIsString glLoadProgramNV 3
ArgumentIsString glProgramString 3
ArgumentIsString glProgramStringARB 3
ArgumentIsString glProgramNamedParameter4fNV 2
ArgumentIsString glProgramNamedParameter4dNV 2
ArgumentIsString glProgramNamedParameter4fvNV 2
ArgumentIsString glProgramNamedParameter4dvNV 2
ArgumentIsString glShaderSource 2
ArgumentIsString glShaderSourceARB 2
ArgumentIsString glCreateShaderProgramv 2

ArgumentIsString glBindFragDataLocation 2
ArgumentIsString glGetFragDataLocation 1
ArgumentIsString glGetUniformIndices 2
ArgumentIsString glGetUniformBlockIndex 1
ArgumentIsString glTransformFeedbackVaryings 2

# String return values must use byte[] etc ..
#   ArgumentIsString glGetActiveAttrib 6
#   ArgumentIsString glGetActiveUniformBlockName 4
#   ArgumentIsString glGetActiveUniformName 4
#   ArgumentIsString glGetActiveUniform 6
#   ArgumentIsString glGetProgramInfoLog 3
#   ArgumentIsString glGetShaderInfoLog 3
#   ArgumentIsString glGetShaderSource 3
#   ArgumentIsString glGetTransformFeedbackVarying 6
#   ArgumentIsString glGetActiveUniformARB 6
#   ArgumentIsString glGetActiveSubroutineName 5
#   ArgumentIsString glGetActiveSubroutineUniformName 5
#   ArgumentIsString glGetNamedStringARB 4 - bug param1 is String r/o see below
#   ArgumentIsString glGetDebugMessageLogARB  7
#   ArgumentIsString glGetDebugMessageLogAMD  6

ArgumentIsString glBindFragDataLocationIndexed 3
ArgumentIsString glGetFragDataIndex 1
ArgumentIsString glGetSubroutineIndex 2
ArgumentIsString glGetSubroutineUniformLocation 2

ArgumentIsString glDebugMessageInsert  5
ArgumentIsString glDebugMessageInsertAMD  4

ArgumentIsString glNamedStringARB 2 4
ArgumentIsString glDeleteNamedStringARB 1
ArgumentIsString glCompileShaderIncludeARB 2
ArgumentIsString glIsNamedStringARB 1
ArgumentIsString glGetNamedStringARB 1
ArgumentIsString glGetNamedStringivARB 1

#
# Use cached GL_EXTENSION if possible,
# which also allows GL3 compatibility.
#
JavaPrologue glGetString  if(_context.isExtensionCacheInitialized()) {
JavaPrologue glGetString    if(GL.GL_EXTENSIONS==name) {
JavaPrologue glGetString        return _context.getGLExtensionsString();
JavaPrologue glGetString    } /* else if(GL.GL_VERSION==name) {
JavaPrologue glGetString        return _context.getGLVersion();
JavaPrologue glGetString    } */
JavaPrologue glGetString  }

#
# Allow special FBO GLContext/GLDrawable to reset to it's
# default FBO framebuffer.
#
JavaPrologue glBindFramebuffer  if( 0 == framebuffer ) {
JavaPrologue glBindFramebuffer      if( GL_FRAMEBUFFER == target || 0x8CA9 /* GL_DRAW_FRAMEBUFFER */ == target ) {
JavaPrologue glBindFramebuffer          framebuffer = _context.getDefaultDrawFramebuffer();
JavaPrologue glBindFramebuffer      } else if( 0x8CA8 /* GL_READ_FRAMEBUFFER */ == target ) {
JavaPrologue glBindFramebuffer          framebuffer = _context.getDefaultReadFramebuffer();
JavaPrologue glBindFramebuffer      }
JavaPrologue glBindFramebuffer  }
JavaEpilogue glBindFramebuffer  _context.setBoundFramebuffer(target, framebuffer);

#
# Directives for Vertex Buffer Object and Pixel Buffer Object checking
#
# NOTE: we currently don't emit glue code for some of these but
# include them for completeness.
#
# FIXME: what about glMultiDrawElements? Do we want to add a VBO
# variant for that, or simply add checks to the top of the current
# implementation?
# 
JavaPrologue glBegin inBeginEndPair = true;
JavaEpilogue glEnd   inBeginEndPair = false;
JavaEpilogue glBindBuffer       bufferStateTracker.setBoundBufferObject({0}, {1});
JavaEpilogue glBindBufferARB    bufferStateTracker.setBoundBufferObject({0}, {1});
JavaEpilogue glBindVertexArray  bufferStateTracker.setBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, {0});
JavaEpilogue glPushClientAttrib bufferStateTracker.clearBufferObjectState();
JavaEpilogue glPushClientAttrib glStateTracker.pushAttrib(mask);
JavaEpilogue glPopClientAttrib  bufferStateTracker.clearBufferObjectState();
JavaEpilogue glPopClientAttrib  glStateTracker.popAttrib();
JavaEpilogue glBufferData       bufferSizeTracker.setBufferSize(bufferStateTracker, {0}, this, {1});

BufferObjectKind Array glColorPointer
BufferObjectKind Array glEdgeFlagPointer
BufferObjectKind Array glElementPointerATI
BufferObjectKind Array glFogCoordPointer
BufferObjectKind Array glFogCoordPointerEXT
# The next one is problematic. It isn't discussed by the specs and
# doesn't have any associated state.
BufferObjectKind Array glInterleavedArrays
BufferObjectKind Array glMatrixIndexPointerARB
BufferObjectKind Array glNormalPointer
BufferObjectKind Array glSecondaryColorPointer
BufferObjectKind Array glSecondaryColorPointerEXT
BufferObjectKind Array glTexCoordPointer
BufferObjectKind Array glVariantPointerEXT
BufferObjectKind Array glVertexPointer
BufferObjectKind Array glVertexAttribPointer
BufferObjectKind Array glVertexAttribPointerARB
BufferObjectKind Array glVertexAttribPointerNV
BufferObjectKind Array glVertexAttribIPointer
BufferObjectKind Array glVertexAttribLPointer
BufferObjectKind Array glVertexWeightPointerEXT
BufferObjectKind Array glWeightPointerARB

BufferObjectKind Element glDrawElements
BufferObjectKind Element glDrawElementsBaseVertex
BufferObjectKind Element glDrawElementsInstanced
BufferObjectKind Element glDrawElementsInstancedBaseInstance
BufferObjectKind Element glDrawElementsInstancedBaseVertex
BufferObjectKind Element glDrawElementsInstancedBaseVertexBaseInstance
BufferObjectKind Element glDrawRangeElements
BufferObjectKind Element glDrawRangeElementsBaseVertex

BufferObjectKind Indirect glDrawArraysIndirect
BufferObjectKind Indirect glDrawElementsIndirect

# There are no PBOs in the embedded OpenGL variants right now
BufferObjectKind UnpackPixel glBitmap
BufferObjectKind UnpackPixel glColorTable
BufferObjectKind UnpackPixel glColorSubTable
BufferObjectKind UnpackPixel glCompressedTexImage1D
BufferObjectKind UnpackPixel glCompressedTexImage1DARB
BufferObjectKind UnpackPixel glCompressedTexImage2D
BufferObjectKind UnpackPixel glCompressedTexImage2DARB
BufferObjectKind UnpackPixel glCompressedTexImage3D
BufferObjectKind UnpackPixel glCompressedTexImage3DARB
BufferObjectKind UnpackPixel glCompressedTexSubImage1D
BufferObjectKind UnpackPixel glCompressedTexSubImage1DARB
BufferObjectKind UnpackPixel glCompressedTexSubImage2D
BufferObjectKind UnpackPixel glCompressedTexSubImage2DARB
BufferObjectKind UnpackPixel glCompressedTexSubImage3D
BufferObjectKind UnpackPixel glCompressedTexSubImage3DARB
BufferObjectKind UnpackPixel glConvolutionFilter1D
BufferObjectKind UnpackPixel glConvolutionFilter2D
BufferObjectKind UnpackPixel glDrawPixels
BufferObjectKind UnpackPixel glPixelMapfv
BufferObjectKind UnpackPixel glPixelMapuiv
BufferObjectKind UnpackPixel glPixelMapusv
BufferObjectKind UnpackPixel glPolygonStipple
BufferObjectKind UnpackPixel glSeparableFilter2D
BufferObjectKind UnpackPixel glTexImage1D
BufferObjectKind UnpackPixel glTexImage2D
BufferObjectKind UnpackPixel glTexImage3D
BufferObjectKind UnpackPixel glTexSubImage1D
BufferObjectKind UnpackPixel glTexSubImage2D
BufferObjectKind UnpackPixel glTexSubImage3D

BufferObjectKind PackPixel glGetColorTable
BufferObjectKind PackPixel glGetCompressedTexImage
BufferObjectKind PackPixel glGetCompressedTexImageARB
BufferObjectKind PackPixel glGetConvolutionFilter
BufferObjectKind PackPixel glGetHistogram
BufferObjectKind PackPixel glGetMinmax
BufferObjectKind PackPixel glGetPixelMapfv
BufferObjectKind PackPixel glGetPixelMapuiv
BufferObjectKind PackPixel glGetPixelMapusv
BufferObjectKind PackPixel glGetPolygonStipple
BufferObjectKind PackPixel glGetSeparableFilter
BufferObjectKind PackPixel glGetTexImage
BufferObjectKind PackPixel glReadPixels

# Range check directives for various routines
# FIXME: some of these are really the bare minimum and won't catch
# many classes of errors. Should extend the DebugGL to perform much
# more error checking with e.g. glDrawElements.
RangeCheck glColorPointer                       3 1

RangeCheck glDrawElements                                3 {1}
RangeCheck glDrawElementsBaseVertex                      3 {1}
RangeCheck glDrawElementsInstanced                       3 {1}
RangeCheck glDrawElementsInstancedBaseInstance           3 {1}
RangeCheck glDrawElementsInstancedBaseVertex             3 {1}
RangeCheck glDrawElementsInstancedBaseVertexBaseInstance 3 {1}
RangeCheck glDrawRangeElements                           5 {3}
RangeCheck glDrawRangeElementsBaseVertex                 5 {3}

RangeCheck glDrawArraysIndirect                          1 1
RangeCheck glDrawElementsIndirect                        2 1

RangeCheck glEdgeFlagPointer          1 1
RangeCheck glElementPointerATI        1 1
RangeCheck glFogCoordPointer          2 1
RangeCheck glFogCoordPointerEXT       2 1
RangeCheck glInterleavedArrays        2 1
RangeCheck glMatrixIndexPointerARB    3 1
RangeCheck glNormalPointer            2 1
RangeCheck glSecondaryColorPointer    3 1
RangeCheck glSecondaryColorPointerEXT 3 1
RangeCheck glTexCoordPointer          3 1
RangeCheck glVariantPointerEXT        3 1
RangeCheck glVertexPointer            3 1
RangeCheck glVertexAttribPointer      5 1
RangeCheck glVertexAttribIPointer     4 1
RangeCheck glVertexAttribLPointer     4 1
RangeCheck glVertexAttribPointerARB   5 1
RangeCheck glWeightPointerARB         3 1

# Give ourselves the texture width and height for range checking inside glGetTexImage
JavaPrologue glGetTexImage int width = 0, height = 0, depth = 1;
JavaPrologue glGetTexImage int[] tmp = new int[1];
JavaPrologue glGetTexImage glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, tmp, 0);
JavaPrologue glGetTexImage width = tmp[0];
JavaPrologue glGetTexImage glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, tmp, 0);
JavaPrologue glGetTexImage height = tmp[0];
JavaPrologue glGetTexImage if (target == GL_TEXTURE_3D) {
JavaPrologue glGetTexImage     glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, tmp, 0);
JavaPrologue glGetTexImage     depth = tmp[0];
JavaPrologue glGetTexImage }

# Range check directives for various image-related routines
RangeCheckBytes glColorTable          5 imageSizeInBytes({3}, {4}, {2}            , 1              , 1    , false)
RangeCheckBytes glColorTableEXT       5 imageSizeInBytes({3}, {4}, {2}            , 1              , 1    , false)
RangeCheckBytes glConvolutionFilter1D 5 imageSizeInBytes({3}, {4}, {2}            , 1              , 1    , false)
RangeCheckBytes glConvolutionFilter2D 6 imageSizeInBytes({4}, {5}, {2}            , {3}            , 1    , false)
RangeCheckBytes glDrawPixels          4 imageSizeInBytes({2}, {3}, {0}            , {1}            , 1    , false)
RangeCheckBytes glReadPixels          6 imageSizeInBytes({4}, {5}, {2}            , {3}            , 1    , true)
RangeCheckBytes glTexImage1D          7 imageSizeInBytes({5}, {6}, {3}            , 1              , 1    , false)
RangeCheckBytes glTexImage2D          8 imageSizeInBytes({6}, {7}, {3}            , {4}            , 1    , false)
RangeCheckBytes glTexImage3D          9 imageSizeInBytes({7}, {8}, {3}            , {4}            , {5}  , false)
RangeCheckBytes glTexSubImage1D       6 imageSizeInBytes({4}, {5}, {3}            , 1              , 1    , false)
RangeCheckBytes glTexSubImage2D       8 imageSizeInBytes({6}, {7}, {4}            , {5}            , 1    , false)
RangeCheckBytes glTexSubImage3D      10 imageSizeInBytes({8}, {9}, {5}            , {6}            , {7}  , false)
# This may produce wrong answers for 1D textures
RangeCheckBytes glGetTexImage         4 imageSizeInBytes({2}, {3}, width          , height         , depth, true)
# Note we don't support glTexImage4DSGIS / glTexSubImage4DSGIS
# FIXME: add the following unpack operations:
#   glBitmap, glPolygonStipple
# and the following pack operations:
#   glGetColorTable, glGetConvolutionFilter, glGetSeparableFilter, glGetHistogram, glGetMinmax

# Range checks for server-side object creation and deletion methods
RangeCheck glGenBuffers               1 {0}
RangeCheck glDeleteBuffers            1 {0}
RangeCheck glGenBuffersARB            1 {0}
RangeCheck glDeleteBuffersARB         1 {0}
RangeCheck glGenFencesAPPLE           1 {0}
RangeCheck glDeleteFencesAPPLE        1 {0}
RangeCheck glGenFencesNV              1 {0}
RangeCheck glDeleteFencesNV           1 {0}
RangeCheck glGenFramebuffersEXT       1 {0}
RangeCheck glDeleteFramebuffersEXT    1 {0}
RangeCheck glGenOcclusionQueriesNV    1 {0}
RangeCheck glDeleteOcclusionQueriesNV 1 {0}
RangeCheck glGenProgramsARB           1 {0}
RangeCheck glDeleteProgramsARB        1 {0}
RangeCheck glGenProgramsNV            1 {0}
RangeCheck glDeleteProgramsNV         1 {0}
RangeCheck glGenQueries               1 {0}
RangeCheck glDeleteQueries            1 {0}
RangeCheck glGenQueriesARB            1 {0}
RangeCheck glDeleteQueriesARB         1 {0}
RangeCheck glGenRenderbuffersEXT      1 {0}
RangeCheck glDeleteRenderbuffersEXT   1 {0}
RangeCheck glGenTextures              1 {0}
RangeCheck glDeleteTextures           1 {0}
RangeCheck glGenVertexArraysAPPLE     1 {0}
RangeCheck glDeleteVertexArraysAPPLE  1 {0}

# Javadoc for the GL class
ClassJavadoc GL /**
ClassJavadoc GL  * <p> Common interface containing the subset of all profiles, GL3bc, GL3, GL2, GLES1 and GLES2.<br/>
ClassJavadoc GL  * This interface reflects common data types, texture and framebuffer functionality.</p>
ClassJavadoc GL  */

ClassJavadoc GL2ES1 /**
ClassJavadoc GL2ES1  * <p> 
ClassJavadoc GL2ES1  * Interface containing the common subset of GL2 and GLES1.<br/>
ClassJavadoc GL2ES1  * This interface reflects only the fixed functionality of OpenGL<br/>
ClassJavadoc GL2ES1  * </p>
ClassJavadoc GL2ES1  */

ClassJavadoc GL2ES2 /**
ClassJavadoc GL2ES2  * <p> 
ClassJavadoc GL2ES2  * Interface containing the common subset of GL3, GL2 and GLES2.<br/>
ClassJavadoc GL2ES2  * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL<br/>
ClassJavadoc GL2ES2  * This interface is almost GLES2 complete.<br/>
ClassJavadoc GL2ES2  * </p>
ClassJavadoc GL2ES2  */

ClassJavadoc GL2ES3 /**
ClassJavadoc GL2ES3  * <p> 
ClassJavadoc GL2ES3  * Interface containing the common subset of core GL2 and GLES3 (OpenGL ES 3.0).<br/>
ClassJavadoc GL2ES3  * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL<br/>
ClassJavadoc GL2ES3  * This interface is not GLES3 complete and merely exist to avoid duplicated definitions.<br/>
ClassJavadoc GL2ES3  * </p>
ClassJavadoc GL2ES3  */

ClassJavadoc GL3ES3 /**
ClassJavadoc GL3ES3  * <p> 
ClassJavadoc GL3ES3  * Interface containing the common subset of core GL3 (OpenGL 3.1+) and GLES3 (OpenGL ES 3.0).<br/>
ClassJavadoc GL3ES3  * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL<br/>
ClassJavadoc GL3ES3  * This interface is almost GLES3 complete, lacking <code>GL_ARB_ES3_compatibility</code> extension.<br/>
ClassJavadoc GL3ES3  * </p>
ClassJavadoc GL3ES3  */

ClassJavadoc GL4ES3 /**
ClassJavadoc GL4ES3  * <p> 
ClassJavadoc GL4ES3  * Interface containing the common subset of core GL4 (OpenGL 4.0+) and GLES3 (OpenGL ES 3.0).<br/>
ClassJavadoc GL4ES3  * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL<br/>
ClassJavadoc GL4ES3  * This interface is GLES3 complete w/o vendor extensions.<br/>
ClassJavadoc GL4ES3  * </p>
ClassJavadoc GL4ES3  */

ClassJavadoc GL2GL3 /**
ClassJavadoc GL2GL3  * <p> 
ClassJavadoc GL2GL3  * Interface containing the common subset of core GL3 (OpenGL 3.1+) and GL2,
ClassJavadoc GL2GL3  * also known as the OpenGL 3.0 forward compatible, non deprecated subset.<br/>
ClassJavadoc GL2GL3  * This interface reflects only the programmable shader functionality of desktop OpenGL<br/>
ClassJavadoc GL2GL3  * </p>
ClassJavadoc GL2GL3  */

ClassJavadoc GL2 /**
ClassJavadoc GL2  * <p> 
ClassJavadoc GL2  * This interface contains all OpenGL [ 1.0 .. 3.0 ] methods,
ClassJavadoc GL2  * as well as most of it's extensions defined at the time of this specification.
ClassJavadoc GL2  * </p>
ClassJavadoc GL2  * <p>
ClassJavadoc GL2  * OpenGL extensions whose functionality was incorporated into core OpenGL &le; 3.0, 
ClassJavadoc GL2  * are subsumed into the core namespace.</p>
ClassJavadoc GL2  * </p>
ClassJavadoc GL2  */

ClassJavadoc GL3 /**
ClassJavadoc GL3  * <p>This interface contains all OpenGL [ 3.1 .. 3.3 ] <i>core</i> methods,
ClassJavadoc GL3  * as well as most of it's extensions defined at the time of this specification.</p>
ClassJavadoc GL3  * <p>Note: OpenGL [ 3.1 .. 3.3 ] core profile does not includes fixed point functionality.</p>
ClassJavadoc GL3  */

ClassJavadoc GL3bc /**
ClassJavadoc GL3bc  * <p>This interface contains all OpenGL [ 3.1 .. 3.3 ] <i>compatibility</i>  methods,
ClassJavadoc GL3bc  * as well as most of it's extensions defined at the time of this specification.</p>
ClassJavadoc GL3bc  * <p>Note: OpenGL [ 3.1 .. 3.3 ] compatibility profile does includes fixed point functionality.</p>
ClassJavadoc GL3bc  */

ClassJavadoc GL4 /**
ClassJavadoc GL4  * <p>This interface contains all OpenGL [ 4.0 .. 4.3 ] <i>core</i> methods,
ClassJavadoc GL4  * as well as most of it's extensions defined at the time of this specification.</p>
ClassJavadoc GL4  * <p>Note: OpenGL [ 4.0 .. 4.3 ] core profile does not includes fixed point functionality.</p>
ClassJavadoc GL4  */

ClassJavadoc GL4bc /**
ClassJavadoc GL4bc  * <p>This interface contains all OpenGL [ 4.0 .. 4.3 ] <i>compatibility</i> profile,
ClassJavadoc GL4bc  * as well as most of it's extensions defined at the time of this specification.</p>
ClassJavadoc GL4bc  * <p>Note: OpenGL [ 4.0 .. 4.3 ] compatibility profile does includes fixed point functionality.</p>
ClassJavadoc GL4bc  */

ClassJavadoc GLES1 /**
ClassJavadoc GLES1  * <p>This interface contains all OpenGL ES [ 1.0 .. 1.1 ] methods,
ClassJavadoc GLES1  * as well as most of it's extensions defined at the time of this specification.</p>
ClassJavadoc GLES1  */

ClassJavadoc GLES2 /**
ClassJavadoc GLES2  * <p>This interface contains all OpenGL ES 2.0 methods,
ClassJavadoc GLES2  * as well as most of it's extensions defined at the time of this specification.</p>
ClassJavadoc GLES2  */

ClassJavadoc GLES3 /**
ClassJavadoc GLES3  * <p>This interface contains all OpenGL ES 3.0 methods,
ClassJavadoc GLES3  * as well as most of it's extensions defined at the time of this specification.</p>
ClassJavadoc GLES3  */

# Javadoc for the EGL class
ClassJavadoc EGL /**
ClassJavadoc EGL  * Provides access to the embedded-specific OpenGL vendor extensions.
ClassJavadoc EGL  * See {@link GLBase} for more information.
ClassJavadoc EGL  */

# Javadoc for the WGL class
ClassJavadoc WGL /**
ClassJavadoc WGL  * Provides access to the Windows-specific OpenGL vendor extensions.
ClassJavadoc WGL  * See {@link GLBase} for more information.
ClassJavadoc WGL  */

# Javadoc for the GLX class
ClassJavadoc GLX /**
ClassJavadoc GLX  * Provides access to the X11-specific OpenGL vendor extensions.
ClassJavadoc GLX  * See {@link GLBase} for more information.
ClassJavadoc GLX  */

# Javadoc for the CGL class
ClassJavadoc CGL /**
ClassJavadoc CGL  * Provides access to the MacOSX-specific OpenGL vendor extensions.
ClassJavadoc CGL  * See {@link GLBase} for more information.
ClassJavadoc CGL  */

# Javadoc for the XVisualInfo class
ClassJavadoc XVisualInfo /**
ClassJavadoc XVisualInfo  * Wrapper for the XVisualInfo data structure, referenced by some GLX OpenGL
ClassJavadoc XVisualInfo  * extensions. No other access is provided to these data structures so currently
ClassJavadoc XVisualInfo  * this wrapper is not useful to end users, though it is used in the implementation.
ClassJavadoc XVisualInfo  */