  '
  '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
  '
  !*glActiveTexture  (int texture)
  !*glClientActiveTexture  (int texture)
  !*glMultiTexCoord2f(int i, float s,t)
  '
  'Shaders
  !*glCreateShader       (int shadertype) as int

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

  !*glCompileShader      (int shader)

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

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

  !*glAttachShader       (int program,shader)

  !*glDetachShader       (int program,shader)

  !*glDeleteShader       (int shader)

  !*glLinkProgram        (int program)

  !*glCreateProgram      () as int

  !*glDeleteProgram      (int program)

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

  !*glUseProgram         (int program)

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

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

  !*glUniform1i          (int location, int v)

  !*glUniform1f          (int location, float v1)

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

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

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

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

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

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

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

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

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

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

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

  def SetFun '(name)
  ==================
  @%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 glGenBuffers
  SetFun glBindBuffer
  SetFun glBufferData
  SetFun glDeleteBuffers
  '
  SetFun glActiveTexture
  SetFun glClientActiveTexture
  SetFun glMultiTexCoord2f
  '
  '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
  '
