  '
  'equates from glext.h
  '======
  '
  % GL_ARRAY_BUFFER         0x8892

  % GL_ELEMENT_ARRAY_BUFFER 0x8893

  % GL_STATIC_DRAW          0x88E4

  '

  /* Shaders */

  % GL_FRAGMENT_SHADER                   0x8B30

  % GL_GEOMETRY_SHADER                   0x8DD9
  % GL_VERTEX_SHADER                     0x8B31

  % GL_MAX_VERTEX_ATTRIBS                0x8869

  % GL_MAX_VERTEX_UNIFORM_VECTORS        0x8DFB

  % GL_MAX_VARYING_VECTORS               0x8DFC

  % GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS  0x8B4D

  % GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS    0x8B4C

  % GL_MAX_TEXTURE_IMAGE_UNITS           0x8872

  % GL_MAX_FRAGMENT_UNIFORM_VECTORS      0x8DFD

  % GL_SHADER_TYPE                       0x8B4F

  % GL_DELETE_STATUS                     0x8B80

  % GL_LINK_STATUS                       0x8B82

  % GL_VALIDATE_STATUS                   0x8B83

  % GL_ATTACHED_SHADERS                  0x8B85

  % GL_ACTIVE_UNIFORMS                   0x8B86

  % GL_ACTIVE_UNIFORM_MAX_LENGTH         0x8B87

  % GL_ACTIVE_ATTRIBUTES                 0x8B89

  % GL_ACTIVE_ATTRIBUTE_MAX_LENGTH       0x8B8A

  % GL_SHADING_LANGUAGE_VERSION          0x8B8C

  % GL_CURRENT_PROGRAM                   0x8B8D

  /* Shader Source */

  % GL_COMPILE_STATUS                    0x8B81

  % GL_INFO_LOG_LENGTH                   0x8B84

  % GL_SHADER_SOURCE_LENGTH              0x8B88

  % GL_SHADER_COMPILER                   0x8DFA

  '
  % GL_TEXTURE_CUBE_MAP                  0x8513
  % GL_TEXTURE_BINDING_CUBE_MAP          0x8514
  % GL_TEXTURE_CUBE_MAP_POSITIVE_X       0x8515
  % GL_TEXTURE_CUBE_MAP_NEGATIVE_X       0x8516
  % GL_TEXTURE_CUBE_MAP_POSITIVE_Y       0x8517
  % GL_TEXTURE_CUBE_MAP_NEGATIVE_Y       0x8518
  % GL_TEXTURE_CUBE_MAP_POSITIVE_Z       0x8519
  % GL_TEXTURE_CUBE_MAP_NEGATIVE_Z       0x851A
  % GL_PROXY_TEXTURE_CUBE_MAP            0x851B
  % GL_MAX_CUBE_MAP_TEXTURE_SIZE         0x851C
  '
  % GL_TEXTURE_CUBE_MAP_SEAMLESS      0x884F
  '
  % GL_GENERATE_MIPMAP                0x8191
  % GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
  % GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
  % GL_CLAMP_TO_EDGE                  0x812F
  '
  % GL_PRIMITIVE_RESTART_FIXED_INDEX  0x8D69

  '
  % GL_TEXTURE0                       0x84C0 '0..31
  % GL_ACTIVE_TEXTURE_ARB             0x84E0

  % GL_FRAMEBUFFER                    0x8D40
  % GL_RENDERBUFFER                   0x8D41
  % GL_DEPTH_COMPONENT                0x1902
  % GL_DEPTH_ATTACHMENT               0x8D00
  % GL_DEPTH_STENCIL                  0x84F9

  % GL_DEPTH_STENCIL_ATTACHMENT       0x821A
  % GL_DEPTH24_STENCIL8               0x88F0
  % GL_UNSIGNED_INT_24_8              0x84FA
  % GL_COLOR_ATTACHMENT0              0x8CE0
  % GL_FRAMEBUFFER_COMPLETE           0x8CD5
  '
  % GL_HALF_FLOAT_ARB                 0x140B


  typedef unsigned short GLhalf;


  'declare pointered functions
  '===========================
  '
  extern export
  '
  !*glActiveTexture  (int texture) link export
  !*glClientActiveTexture  (int texture) link export
  !*glMultiTexCoord2f(int i, float s,t) link export
  '
  'Shaders
  !*glCreateShader       (int shadertype) as int  link export

  !*glShaderSource       (int shader,count,sys strings, int lengths) link export

  !*glCompileShader      (int shader) link export

  !*glGetShaderInfoLog   (int shader,maxlength,*length,char*infolog) link export  
  !*glGetProgramInfoLog  (int shader,maxlength,*length,char*infolog) link export

  !*glGetShaderiv        (int shader,pname,*params) link export

  !*glAttachShader       (int program,shader) link export

  !*glDetachShader       (int program,shader) link export

  !*glDeleteShader       (int shader) link export

  !*glLinkProgram        (int program) link export

  !*glCreateProgram      () as int link export

  !*glDeleteProgram      (int program) link export

  !*glGetProgramiv       (int program,pname,*params) link export

  !*glUseProgram         (int program) link export

  !*glGetUniformLocation (int program, char*name) as int link export

  !*glGetUniformfv       (int program,location,float*params) link export

  !*glUniform1i          (int location, int v) link export

  !*glUniform1f          (int location, float v1) link export

  !*glUniform2f          (int location, float v1,v2) link export

  !*glUniform3f          (int location, float v1,v2,v3) link export

  !*glUniform4f          (int location, float v1,v2,v3,v4) link export

  !*glUniform1iv         (int location, count, int*v) link export

  !*glUniform1fv         (int location, count, float *v) link export

  !*glUniform2fv         (int location, count, float *v) link export

  !*glUniform3fv         (int location, count, float *v) link export

  !*glUniform4fv         (int location, count, float *v) link export

  !*glUniformMatrix3fv   (int location, count, transpose, float *v) link export

  !*glUniformMatrix4fv   (int location, count, transpose, float *v) link export

  '
  'VERTEX BUFFER OBJECTS
  !*glGenBuffers(int n, *buffers) link export
  !*glBindBuffer(sys target, buffer) link export
  !*glBufferData(sys target, size, pdat, usage) link export
  !*glDeleteBuffers(int n, *buffers) link export
  '
  'ATTRIBUTE ARRAY
  !* glVertexAttribPointer (int index, size, type, normalized, stride, pointer) link export
  !* glVertexAttribDivisor( int location, divisor ) link export
  !* glGetAttribLocation(int program, char* name) link export
  !* glEnableVertexAttribArray(int location) link export
  !* glDisableVertexAttribArray(int location) link export
  'MULTIDRAW
  !* glMultiDrawArrays( int mode, *first, *count, primcount) link export
  !* glMultiDrawElements( int mode, *count, type, **indices, primcount) link export
  'BASE VERTEX
  !* glDrawElementsBaseVertex( int mode, count, type, *indices, basevertex) link export
  'INSTANCE
  !* glDrawArraysInstanced( int mode, first, count, instancecount) link export
  !* glDrawElementsInstanced( int mode, GLsizei count, type, *indices, instancecount ) link export
  !* glDrawArraysInstancedBaseInstance( int mode, first, count, instancecount, baseinstance) link export
  'RANGE
  !* glDrawElementsInstancedBaseInstance( int mode, count, type, *indices, instancecount, baseinstance) link export
  !* glDrawRangeElements( int mode, start, end, count, type, *indices) link export
  'COMBINATIONS
  !* glMultiDrawElementsBaseVertex( int mode, *count, type, **indices, primcount, *basevertex ) link export
  !* glDrawRangeElementsBaseVertex( int mode, start, end, count, type, *indices, basevertex ) link export
  !* glDrawElementsInstancedBaseVertex( int mode, count, type, *indices, instancecount, basevertex ) link export
  !* glDrawElementsInstancedBaseVertexBaseInstance( int mode, count, type, *indices, instancecount, basevertex, baseinstance ) link export
  'FEEDBACK
  !* glDrawTransformFeedback( int mode, id) link export
  !* glDrawTransformFeedbackStream( int mode, id, stream ) link export
  !* glDrawTransformFeedbackInstanced( int mode, id, instancecount ) link export
  !* glDrawTransformFeedbackStreamInstanced( int mode, id, stream, instancecount ) link export
  'INDIRECT
  !* glDrawArraysIndirect( int mode, *indirect ) link export
  type DrawArraysIndirectCommand { int  count, instanceCount, first, baseInstance }
  !* glMultiDrawArraysIndirect( int mode, *indirect, drawcount, stride ) link export
  !* glDrawElementsIndirect( int mode, type, *indirect ) link export
  type  struct DrawElementsIndirectCommand { int count, instanceCount, firstIndex, baseVertex, baseInstance }
  !* glMultiDrawElementsIndirect( int mode, type, *indirect, drawcount, stride ) link export
  'CONDITIONAL RENDERING
  % GL_QUERY_NO_WAIT                  0x8E14
  % GL_QUERY_BY_REGION_WAIT           0x8E15
  % GL_QUERY_BY_REGION_NO_WAIT        0x8E16
  !* glBeginConditionalRender( int id, mode ) link export
  !* glEndConditionalRender() link export
  'FRAME BUFFER TO TEXTURE
  !* glGenFramebuffers( int n, *framebuffers ) link export
  !* glBindFramebuffer( int target, framebuffer ) link export
  !* glGenRenderbuffers( int n, *renderbuffers ) link export
  !* glBindRenderbuffer( int target, renderbuffer ) link export
  !* glRenderbufferStorage(int target, internalformat, width, height) link export
  !* glFramebufferRenderbuffer( int target, attachmnet, renderbuffertarget, renderbuffer ) link export
  !* glFramebufferTexture( int target, attachment, texture, level ) link export
  !* glFramebufferTexture2D( int target, attachment, textarget, texture, level ) link export
  !* glDrawBuffers( int n,*buffers ) link export
  !* glCheckFramebufferStatus( int target ) link export
  !* glDeleteRenderbuffers( int n, *renderbuffers ) link export
  !* glDeleteFramebuffers( int n, *framebuffers ) link export
  '
  end extern

  def SetFun '(name)
  ==================
  ' !* fun () as sys link export
  _%1=wglGetProcAddress "%1"
  if _%1=0 then print "%1?" ': exit sub
  '@%1=wglGetProcAddress "%1"
  'if @%1=0 then print "%1?" ': exit sub
  end def


  def SetFunARB '(name)
  =====================
  @%1=wglGetProcAddress "%1ARB"
  if @%1=0 then print "%1ARB ?"
  end def

  def SetFunNV '(name)
  ====================
  @%1=wglGetProcAddress "%1NV"
  if @%1=0 then print "%1NV ?"
  end def


  sub SetupExtFunctions()
  =======================
  '
  'bind to buffer functions
  '
  SetFun glActiveTexture
  SetFun glClientActiveTexture
  SetFun glMultiTexCoord2f

  SetFun glGenBuffers
  SetFun glBindBuffer
  SetFun glBufferData
  SetFun glDeleteBuffers
  '
  'bind to GLSL functions
  SetFun glCreateShader
  SetFun glShaderSource
  SetFun glCompileShader
  SetFun glGetShaderInfoLog
  SetFun glGetProgramInfoLog
  SetFun glGetShaderiv
  SetFun glAttachShader
  SetFun glDetachShader
  SetFun glDeleteShader
  SetFun glLinkProgram
  SetFun glCreateProgram
  SetFun glDeleteProgram
  SetFun glGetProgramiv
  SetFun glUseProgram
  SetFun glGetUniformLocation
  SetFun glGetUniformfv
  SetFun glUniform1i
  SetFun glUniform1f
  SetFun glUniform2f
  SetFun glUniform3f
  SetFun glUniform4f
  SetFun glUniform1iv
  SetFun glUniform1fv
  SetFun glUniform2fv
  SetFun glUniform3fv
  SetFun glUniform4fv
  SetFun glUniformMatrix3fv
  SetFun glUniformMatrix4fv
  '
  'ATTRIBUTE ARRAY
  SetFun glGetAttribLocation
  SetFun glVertexAttribPointer
  SetFun glVertexAttribDivisor
  SetFun glEnableVertexAttribArray
  SetFun glDisableVertexAttribArray
  'MULTIDRAW
  SetFun glMultiDrawArrays
  SetFun glMultiDrawElements
  'BASE VERTEX
  SetFun glDrawElementsBaseVertex
  'INSTANCE
  SetFun glDrawArraysInstanced
  SetFun glDrawElementsInstanced
  SetFun glDrawArraysInstancedBaseInstance
  'RANGE
  SetFun glDrawElementsInstancedBaseInstance
  SetFun glDrawRangeElements
  'COMBINATIONS
  SetFun glMultiDrawElementsBaseVertex
  SetFun glDrawRangeElementsBaseVertex
  SetFun glDrawElementsInstancedBaseVertex
  SetFun glDrawElementsInstancedBaseVertexBaseInstance
  'FEEDBACK
  SetFun glDrawTransformFeedback
  SetFun glDrawTransformFeedbackStream
  SetFun glDrawTransformFeedbackInstanced
  SetFun glDrawTransformFeedbackStreamInstanced
  ''INDIRECT
  SetFun glDrawArraysIndirect
  type DrawArraysIndirectCommand { int  count, instanceCount, first, baseInstance }
  SetFun glMultiDrawArraysIndirect
  SetFun glDrawElementsIndirect
  type  struct DrawElementsIndirectCommand { int count, instanceCount, firstIndex, baseVertex, baseInstance }
  SetFun glMultiDrawElementsIndirect

  'CONDITIONAL RENDERING
  SetFun glBeginConditionalRender
  SetFun glEndConditionalRender

  'FRAME BUFFER TO TEXTURE
  SetFun glGenFramebuffers
  SetFun glBindFramebuffer
  SetFun glGenRenderbuffers
  SetFun glBindRenderbuffer
  SetFun  glRenderbufferStorage
  SetFun glFramebufferRenderbuffer
  SetFun glFramebufferTexture
  SetFun glFramebufferTexture2D  '
  SetFun glDrawBuffers
  SetFun glCheckFramebufferStatus
  SetFun glDeleteRenderbuffers
  SetFun glDeleteFramebuffers

  end sub
  '
