;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; $Id: opengl.lsh,v 1.4 2004/01/18 05:15:52 leonb Exp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(libload "dh-compile")
(libload "libc/constants")
(libload "opengl-config")
(libload "glenum")


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; OpenGL interface
;; This is done from the gl.h file that comes with the public
;; domain OpenGL implementation valled Mesa
;; It's got everything except extensions and SGI-specific stuff.
;; Yann LeCun 1997.

#? ** OpenGL Bindings.
;; Opengl.lsh is a complete interface between SN and the industry-standard
;; 3D graphic library OpenGL. With opengl.sn all OpenGL-1.1 functions can 
;; be called from SN, and all the predefined constants can be used.
;; OpenGL windows are open using the facilities provided by the 
;; gl/glut.lsh package. Another package gl/openglu.sn provides an interface
;; with the higher-level OpenGLU functions including object tesselations, 
;; NURBS, mipmap building, polygons....
;; The Lush equivalents to OpenGL functions have the same name as their C 
;; counterparts. The arguments are also identical to the C version, except
;; that structure pointers are generic pointers, and pointers to arrays
;; of numbers are transformed into Lush matrices with the corresponding type.
;; So for example, the Lush version of the function glPixelMapfv whose C 
;; prototype is glPixelMapfv(int,int,float*) takes two ints and an idx1
;; of floats as arguments. 
;; The only exception to this rule is when the type of the numbers in the
;; array is unspecified at compile time. In this case, the SN function
;; takes a gptr (the C function takes a void*).
;; The functions to which this exception applies are:
;; glPolygonStipple, glGetPolygonStipple, glEdgeFlagv, glReadPixels,
;; glDrawPixels, glTexImage1D, glTexImage2D, and glGetTexImage.
;; 
;; The functions implemented here are the ones that are present in
;; the gl.h file distributed with the public domain implementation
;; of OpenGL called Mesa.
;; 
;; No explicit documentation is provided for the functions. Developers
;; are referred to the OpenGL manuals.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; types

(defvar GLenum -int-)
(defvar GLboolean -bool-)
(defvar GLbitfield -int-)
(defvar GLbyte -byte-)
(defvar GLshort -short-)
(defvar GLint -int-)
(defvar GLubyte -ubyte-)
(defvar GLushort -short-)
(defvar GLuint -int-)
(defvar GLsizei -int-)
(defvar GLfloat -float-)
(defvar GLclampf -float-)
(defvar GLdouble -double-)
(defvar GLclampd -double-)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;

(de glClearIndex( c )
    (cheader "#include <GL/gl.h>")
    ((GLfloat) c)
    #{ glClearIndex($c); #} ())

(de glClearColor(red green blue alpha)
    ((GLclampf) red)
    ((GLclampf) green)
    ((GLclampf) blue)
    ((GLclampf) alpha)
    #{ glClearColor($red, $green, $blue, $alpha); #} ())

(de glClear( mask )
    ((GLbitfield) mask)
    #{ glClear($mask); #} ())

(de glIndexMask( mask )
    ((GLuint) mask)
    #{ glIndexMask($mask); #} ())

(de glColorMask( red green blue alpha)
    ((GLboolean) red green blue alpha)
    #{ glColorMask( $red, $green, $blue, $alpha ); #} ())

(de glAlphaFunc( func ref )
    ((GLenum) func)
    ((GLclampf) ref)
    #{ glAlphaFunc( $func, $ref ); #} ())

(de glBlendFunc( sfactor dfactor )
    ((GLenum) sfactor dfactor )
    #{ glBlendFunc( $sfactor, $dfactor ); #} ())

(de glLogicOp( opcode )
    ((GLenum) opcode )
    #{ glLogicOp( $opcode ); #} ())

(de glCullFace( mode )
    ((GLenum) mode )
    #{ glCullFace( $mode ); #} ())

(de glFrontFace( mode )
    ((GLenum) mode )
    #{ glFrontFace( $mode ); #} ())

(de glPointSize( size )
    ((GLfloat) size )
    #{ glPointSize( $size ); #} ())

(de glLineWidth( width )
    ((GLfloat) width )
    #{ glLineWidth( $width ); #} ())

(de glLineStipple( factor pattern )
    ((GLint) factor)
    ((GLushort) pattern)
    #{ glLineStipple( $factor, $pattern ); #} ())

(de glPolygonMode( face mode )
    ((GLenum) face mode )
    #{ glPolygonMode( $face, $mode ); #} ())

(de glPolygonStipple( mask )
    ((-gptr- "GLubyte *") mask)
    #{ glPolygonStipple( $mask ); #} ())

(de glGetPolygonStipple( mask )
    ((-gptr- "GLubyte *") mask)
    #{ glGetPolygonStipple( $mask ); #} ())

(de glEdgeFlag( flag )
    ((GLboolean) flag )
    #{ glEdgeFlag( $flag ); #} ())

(de glEdgeFlagv( flag )
    ((-gptr- "GLboolean *") flag)
    #{ glEdgeFlagv( $flag ); #} ())

(de glScissor( x y width height)
    ((GLint) x y)
    ((GLsizei) width height)
    #{ glScissor( $x, $y, $width, $height); #} ())

(de glClipPlane( plane equation )
    ((GLenum) plane)
    ((-gptr- "GLdouble *") equation)
    #{ glClipPlane( $plane, $equation ); #} ())

(de glGetClipPlane( plane equation )
    ((GLenum) plane)
    ((-gptr- "GLdouble *") equation )
    #{ glGetClipPlane( $plane, $equation ); #} ())

(de glDrawBuffer( mode )
    ((GLenum) mode )
    #{ glDrawBuffer( $mode ); #} ())

(de glReadBuffer( mode )
    ((GLenum) mode )
    #{ glReadBuffer( $mode ); #} ())

(de glEnable( cap )
    ((GLenum) cap)
    #{ glEnable( $cap ); #} ())

(de glDisable( cap )
    ((GLenum) cap )
    #{ glDisable( $cap ); #} ())

(de glIsEnabled( cap )
    ((GLenum) cap )
    (bool #{ glIsEnabled( $cap ) #}))

(de glGetBooleanv( pname params )
    ((GLenum) pname)
    ((-gptr- "GLboolean *") params )
    #{ glGetBooleanv( $pname, $params ); #} ())

(de glGetDoublev( pname params )
    ((GLenum) pname)
    ((-gptr- "GLdouble *") params)
    #{ glGetDoublev( $pname, $params ); #} ())

(de glGetFloatv( pname params )
    ((GLenum) pname)
    ((-gptr- "GLfloat *") params )
    #{ glGetFloatv( $pname, $params ); #} ())

(de glGetIntegerv( pname params )
    ((GLenum) pname)
    ((-gptr- "GLint *") params )
    #{ glGetIntegerv( $pname, $params ); #} ())


(de glPushAttrib( mask )
    ((GLbitfield) mask )
    #{ glPushAttrib( $mask ); #} ())

(de glPopAttrib()
    #{ glPopAttrib(); #} ())

(de glRenderMode( mode )
    ((GLenum) mode )
    (int #{ glRenderMode( $mode ) #}))

(de glGetError() (int #{ glGetError() #}))

(de glGetString( name )
    ((GLenum) name )
    (gptr #{ glGetString( $name ) #}))

(de glFinish() #{ glFinish(); #} ())

(de glFlush() #{ glFlush(); #} ())

(de glHint(target mode )
    ((GLenum) target mode )
    #{ glHint( $target, $mode ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Depth Buffer

(de glClearDepth( depth )
    ((GLclampd) depth )
    #{ glClearDepth( $depth ); #} ())

(de glDepthFunc( func )
    ((GLenum) func )
    #{ glDepthFunc( $func ); #} ())

(de glDepthMask( flag )
    ((GLboolean) flag )
    #{ glDepthMask( $flag ); #} ())

(de glDepthRange( near_val far_val )
    ((GLclampd) near_val far_val )
    #{ glDepthRange( $near_val, $far_val ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Accumulation Buffer

(de glClearAccum( red green blue alpha)
    ((GLfloat) red green blue alpha)
    #{ glClearAccum( $red, $green, $blue, $alpha); #} ())

(de glAccum( op value )
    ((GLenum) op)
    ((GLfloat) value)
    #{ glAccum( $op, $value ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Transformation

(de glMatrixMode( mode )
    ((GLenum) mode )
    #{ glMatrixMode( $mode ); #} ())

(de glOrtho( left right bottom top near_val far_val )
    ((GLdouble) left right bottom top near_val far_val )
    #{ glOrtho( $left, $right, $bottom, $top, $near_val, $far_val); #} ())

(de glFrustum( left right bottom top near_val far_val )
    ((GLdouble) left right bottom top near_val far_val )
    #{ glFrustum( $left, $right, $bottom, $top, $near_val, $far_val); #} ())

(de glViewport( x y width height)
    ((GLint) x y)
    ((GLsizei) width height )
    #{ glViewport( $x, $y, $width, $height ); #} ())

(de glPushMatrix()
    #{ glPushMatrix(); #} ())

(de glPopMatrix()
    #{ glPopMatrix(); #} ())

(de glLoadIdentity()
    #{ glLoadIdentity(); #} ())

(de glLoadMatrixd( m )
    ((-idx2- (-double-)) m)
    #{ glLoadMatrixd( IDX_PTR($m,double) ); #} ())

(de glLoadMatrixf( m )
    ((-idx2- (-float-)) m)
    #{ glLoadMatrixf( IDX_PTR($m,float) ); #} ())

(de glMultMatrixd( m )
    ((-idx2- (-double-)) m)
    #{ glMultMatrixd( IDX_PTR($m,double) ); #} ())

(de glMultMatrixf( m )
    ((-idx2- (-float-)) m)
    #{ glMultMatrixf( IDX_PTR($m,float) ); #} ())

(de glRotated(angle x y z)
    ((GLdouble) angle x y z)
    #{ glRotated( $angle, $x, $y, $z ); #} ())

(de glRotatef(angle x y z)
    ((GLfloat) angle x y z)
    #{ glRotatef( $angle, $x, $y, $z ); #} ())


(de glScaled(x y z)
    ((GLdouble) x y z)
    #{ glScaled( $x, $y, $z); #} ())

(de glScalef(x y z)
    ((GLfloat) x y z)
    #{ glScalef( $x, $y, $z); #} ())

(de glTranslated(x y z)
    ((GLdouble) x y z)
    #{ glTranslated( $x, $y, $z); #} ())

(de glTranslatef(x y z)
    ((GLfloat) x y z)
    #{ glTranslatef( $x, $y, $z); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Display Lists

(de glIsList( list )
    ((GLuint) list )
    (bool #{ glIsList( $list ) #}))


(de glDeleteLists( list range )
    ((GLuint) list)
    ((GLsizei) range )
    #{ glDeleteLists( $list, $range ); #} ())


(de glGenLists( range )
    ((GLsizei) range )
    (int #{ glGenLists( $range ) #}))


(de glNewList( list mode )
    ((GLuint) list)
    ((GLenum) mode )
    #{ glNewList( $list, $mode ); #} ())

(de glEndList()
    #{ glEndList(); #} ())

(de glCallList( list )
    ((GLuint) list )
    #{ glCallList( $list ); #} ())

(de glCallLists( n type lists )
    ((GLsizei) n)
    ((GLenum) type)
    ((-gptr- "GLvoid *") lists)
    #{ glCallLists( $n, $type, $lists ); #} ())

(de glListBase( base )
    ((GLuint) base )
    #{ glListBase( $base ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Drawing Functions

(de glBegin( mode )
    ((GLenum) mode )
    #{ glBegin( $mode ); #} ())

(de glEnd()
    #{ glEnd(); #} ())


(de glVertex2d(x y)
    ((GLdouble) x y)
    #{ glVertex2d( $x, $y ); #} ())
(de glVertex2f(x y)
    ((GLfloat) x y)
    #{ glVertex2f( $x, $y ); #} ())
(de glVertex2i(x y)
    ((GLint) x y)
    #{ glVertex2i( $x, $y ); #} ())
(de glVertex2s(x y)
    ((GLshort) x y)
    #{ glVertex2s( $x, $y ); #} ())

(de glVertex3d(x y z)
    ((GLdouble) x y z)
    #{ glVertex3d( $x, $y, $z ); #} ())
(de glVertex3f(x y z)
    ((GLfloat) x y z)
    #{ glVertex3f( $x, $y, $z ); #} ())
(de glVertex3i(x y z)
    ((GLint) x y z)
    #{ glVertex3i( $x, $y, $z ); #} ())
(de glVertex3s(x y z)
    ((GLshort) x y z)
    #{ glVertex3s( $x, $y, $z ); #} ())

(de glVertex4d(x y z w)
    ((GLdouble) x y z w)
    #{ glVertex4d( $x, $y, $z, $w ); #} ())
(de glVertex4f(x y z w)
    ((GLfloat) x y z w)
    #{ glVertex4f( $x, $y, $z, $w ); #} ())
(de glVertex4i(x y z w)
    ((GLint) x y z w)
    #{ glVertex4i( $x, $y, $z, $w ); #} ())
(de glVertex4s(x y z w)
    ((GLshort) x y z w)
    #{ glVertex4s( $x, $y, $z, $w ); #} ())

(de glVertex2dv( v );
    ((-idx1- (-double-)) v)
    #{ glVertex2dv(  IDX_PTR($v,double) ); #} ())
(de glVertex2fv( v );
    ((-idx1- (-float-)) v)
    #{ glVertex2fv(  IDX_PTR($v,float) ); #} ())
(de glVertex2iv( v );
    ((-idx1- (-int-)) v)
    #{ glVertex2iv(  IDX_PTR($v,int) ); #} ())
(de glVertex2sv( v );
    ((-idx1- (-short-)) v)
    #{ glVertex2sv(  IDX_PTR($v,short) ); #} ())

(de glVertex3dv( v );
    ((-idx1- (-double-)) v)
    #{ glVertex3dv(  IDX_PTR($v,double) ); #} ())
(de glVertex3fv( v );
    ((-idx1- (-float-)) v)
    #{ glVertex3fv(  IDX_PTR($v,float) ); #} ())
(de glVertex3iv( v );
    ((-idx1- (-int-)) v)
    #{ glVertex3iv(  IDX_PTR($v,int) ); #} ())
(de glVertex3sv( v );
    ((-idx1- (-short-)) v)
    #{ glVertex3sv(  IDX_PTR($v,short) ); #} ())

(de glVertex4dv( v );
    ((-idx1- (-double-)) v)
    #{ glVertex4dv( IDX_PTR($v,double)); #} ())
(de glVertex4fv( v );
    ((-idx1- (-float-)) v)
    #{ glVertex4fv(  IDX_PTR($v,float) ); #} ())
(de glVertex4iv( v );
    ((-idx1- (-int-)) v)
    #{ glVertex4iv(  IDX_PTR($v,int) ); #} ())
(de glVertex4sv( v );
    ((-idx1- (-short-)) v)
    #{ glVertex4sv(  IDX_PTR($v,short) ); #} ())



(de glNormal3b( nx ny nz )
    ((GLbyte) nx ny nz)
    #{ glNormal3b( $nx, $ny, $nz) #} ())
(de glNormal3d( nx ny nz )
    ((GLdouble) nx ny nz)
    #{ glNormal3d( $nx, $ny, $nz) #} ())
(de glNormal3f( nx ny nz )
    ((GLfloat) nx ny nz)
    #{ glNormal3f( $nx, $ny, $nz) #} ())
(de glNormal3i( nx ny nz )
    ((GLint) nx ny nz)
    #{ glNormal3i( $nx, $ny, $nz) #} ())
(de glNormal3s( nx ny nz )
    ((GLshort) nx ny nz)
    #{ glNormal3s( $nx, $ny, $nz) #} ())

(de glNormal3bv( v )
    ((-idx1- (-byte-)) v)
    #{ glNormal3bv( IDX_PTR($v,signed char) ); #} ())
(de glNormal3dv( v )
    ((-idx1- (-double-)) v)
    #{ glNormal3dv(  IDX_PTR($v,double) ); #} ())
(de glNormal3fv( v )
    ((-idx1- (-float-)) v)
    #{ glNormal3fv(  IDX_PTR($v,float) ); #} ())
(de glNormal3iv( v )
    ((-idx1- (-int-)) v)
    #{ glNormal3iv(  IDX_PTR($v,int) ); #} ())
(de glNormal3sv( v )
    ((-idx1- (-short-)) v)
    #{ glNormal3sv(  IDX_PTR($v,short) ); #} ())

(de glIndexd(c) ((GLdouble) c) #{ glIndexd($c); #} ())
(de glIndexf(c) ((GLfloat ) c) #{ glIndexf($c); #} ())
(de glIndexi(c) ((GLint   ) c) #{ glIndexi($c); #} ())
(de glIndexs(c) ((GLshort ) c) #{ glIndexs($c); #} ())

(de glIndexdv(c) ((-idx1- (-double-)) c) #{ glIndexdv(IDX_PTR($c,double)); #} ())
(de glIndexfv(c) ((-idx1- (-float-) ) c) #{ glIndexfv(IDX_PTR($c,float )); #} ())
(de glIndexiv(c) ((-idx1- (-int-)   ) c) #{ glIndexiv(IDX_PTR($c,int   )); #} ())
(de glIndexsv(c) ((-idx1- (-short-) ) c) #{ glIndexsv(IDX_PTR($c,short )); #} ())

(de glColor3b(red green blue)
    ((GLbyte) red green blue)
    #{ glColor3b( $red, $green, $blue); #} ())
(de glColor3d(red green blue)
    ((GLdouble) red green blue)
    #{ glColor3d( $red, $green, $blue); #} ())
(de glColor3f(red green blue)
    ((GLfloat) red green blue)
    #{ glColor3f( $red, $green, $blue); #} ())
(de glColor3i(red green blue)
    ((GLint) red green blue)
    #{ glColor3i( $red, $green, $blue); #} ())
(de glColor3s(red green blue)
    ((GLshort) red green blue)
    #{ glColor3s( $red, $green, $blue); #} ())
(de glColor3ub(red green blue)
    ((GLubyte) red green blue)
    #{ glColor3ub( $red, $green, $blue); #} ())
(de glColor3ui(red green blue)
    ((GLuint) red green blue)
    #{ glColor3ui( $red, $green, $blue); #} ())
(de glColor3us(red green blue)
    ((GLushort) red green blue)
    #{ glColor3us( $red, $green, $blue); #} ())

(de glColor4b(red green blue alpha)
    ((GLbyte) red green blue alpha)
    #{ glColor4b( $red, $green, $blue, $alpha); #} ())
(de glColor4d(red green blue alpha)
    ((GLdouble) red green blue alpha)
    #{ glColor4d( $red, $green, $blue, $alpha); #} ())
(de glColor4f(red green blue alpha)
    ((GLfloat) red green blue alpha)
    #{ glColor4f( $red, $green, $blue, $alpha); #} ())
(de glColor4i(red green blue alpha)
    ((GLint) red green blue alpha)
    #{ glColor4i( $red, $green, $blue, $alpha); #} ())
(de glColor4s(red green blue alpha)
    ((GLshort) red green blue alpha)
    #{ glColor4s( $red, $green, $blue, $alpha); #} ())
(de glColor4ub(red green blue alpha)
    ((GLubyte) red green blue alpha)
    #{ glColor4ub( $red, $green, $blue, $alpha); #} ())
(de glColor4ui(red green blue alpha)
    ((GLuint) red green blue alpha)
    #{ glColor4ui( $red, $green, $blue, $alpha); #} ())
(de glColor4us(red green blue alpha)
    ((GLushort) red green blue alpha)
    #{ glColor4us( $red, $green, $blue, $alpha); #} ())

(de glColor3bv(v) ((-idx1- (-byte-)  ) v) #{ glColor3bv(IDX_PTR($v,signed char  )); #} ())
(de glColor3dv(v) ((-idx1- (-double-)) v) #{ glColor3dv(IDX_PTR($v,double)); #} ())
(de glColor3fv(v) ((-idx1- (-float-) ) v) #{ glColor3fv(IDX_PTR($v,float )); #} ())
(de glColor3iv(v) ((-idx1- (-int-)   ) v) #{ glColor3iv(IDX_PTR($v,int   )); #} ())
(de glColor3sv(v) ((-idx1- (-short-) ) v) #{ glColor3sv(IDX_PTR($v,short )); #} ())
(de glColor3ubv(v) ((-idx1- (-ubyte-)  ) v) 
    #{ glColor3ubv(IDX_PTR($v,unsigned char  )); #} ())
(de glColor3uiv(v) ((-idx1- (-int-)   ) v) 
    #{ glColor3uiv(IDX_PTR($v,unsigned int   )); #} ())
(de glColor3usv(v) ((-idx1- (-short-) ) v) 
    #{ glColor3usv(IDX_PTR($v,unsigned short )); #} ())

(de glColor4bv(v) ((-idx1- (-byte-)  ) v) #{ glColor4bv(IDX_PTR($v,signed char  )); #} ())
(de glColor4dv(v) ((-idx1- (-double-)) v) #{ glColor4dv(IDX_PTR($v,double)); #} ())
(de glColor4fv(v) ((-idx1- (-float-) ) v) #{ glColor4fv(IDX_PTR($v,float )); #} ())
(de glColor4iv(v) ((-idx1- (-int-)   ) v) #{ glColor4iv(IDX_PTR($v,int   )); #} ())
(de glColor4sv(v) ((-idx1- (-short-) ) v) #{ glColor4sv(IDX_PTR($v,short )); #} ())
(de glColor4ubv(v) ((-idx1- (-ubyte-)  ) v) 
    #{ glColor4ubv(IDX_PTR($v,unsigned char  )); #} ())
(de glColor4uiv(v) ((-idx1- (-int-)   ) v) 
    #{ glColor4uiv(IDX_PTR($v,unsigned int   )); #} ())
(de glColor4usv(v) ((-idx1- (-short-) ) v) 
    #{ glColor4usv(IDX_PTR($v,unsigned short )); #} ())

(de glTexCoord1d(s) ((GLdouble) s) #{ glTexCoord1d($s); #} ())
(de glTexCoord1f(s) ((GLfloat)  s) #{ glTexCoord1f($s); #} ())
(de glTexCoord1i(s) ((GLint)    s) #{ glTexCoord1i($s); #} ())
(de glTexCoord1s(s) ((GLshort)  s) #{ glTexCoord1s($s); #} ())

(de glTexCoord2d(s u) ((GLdouble) s u) #{ glTexCoord2d($s,$u); #} ())
(de glTexCoord2f(s u) ((GLfloat)  s u) #{ glTexCoord2f($s,$u); #} ())
(de glTexCoord2i(s u) ((GLint)    s u) #{ glTexCoord2i($s,$u); #} ())
(de glTexCoord2s(s u) ((GLshort)  s u) #{ glTexCoord2s($s,$u); #} ())

(de glTexCoord3d(s u r) ((GLdouble) s u r) #{ glTexCoord3d($s,$u,$r); #} ())
(de glTexCoord3f(s u r) ((GLfloat)  s u r) #{ glTexCoord3f($s,$u,$r); #} ())
(de glTexCoord3i(s u r) ((GLint)    s u r) #{ glTexCoord3i($s,$u,$r); #} ())
(de glTexCoord3s(s u r) ((GLshort)  s u r) #{ glTexCoord3s($s,$u,$r); #} ())

(de glTexCoord4d(s u r q) ((GLdouble) s u r q) #{ glTexCoord4d($s,$u,$r,$q); #} ())
(de glTexCoord4f(s u r q) ((GLfloat)  s u r q) #{ glTexCoord4f($s,$u,$r,$q); #} ())
(de glTexCoord4i(s u r q) ((GLint)    s u r q) #{ glTexCoord4i($s,$u,$r,$q); #} ())
(de glTexCoord4s(s u r q) ((GLshort)  s u r q) #{ glTexCoord4s($s,$u,$r,$q); #} ())

(de glTexCoord1dv(v) ((-idx1- (-double-)) v) #{ glTexCoord1dv(IDX_PTR($v,double)); #} ())
(de glTexCoord1fv(v) ((-idx1- (-float-) ) v) #{ glTexCoord1fv(IDX_PTR($v,float)); #} ())
(de glTexCoord1iv(v) ((-idx1- (-int-)   ) v) #{ glTexCoord1iv(IDX_PTR($v,int)); #} ())
(de glTexCoord1sv(v) ((-idx1- (-short-) ) v) #{ glTexCoord1sv(IDX_PTR($v,short)); #} ())

(de glTexCoord2dv(v) ((-idx1- (-double-)) v) #{ glTexCoord2dv(IDX_PTR($v,double)); #} ())
(de glTexCoord2fv(v) ((-idx1- (-float-) ) v) #{ glTexCoord2fv(IDX_PTR($v,float)); #} ())
(de glTexCoord2iv(v) ((-idx1- (-int-)   ) v) #{ glTexCoord2iv(IDX_PTR($v,int)); #} ())
(de glTexCoord2sv(v) ((-idx1- (-short-) ) v) #{ glTexCoord2sv(IDX_PTR($v,short)); #} ())

(de glTexCoord3dv(v) ((-idx1- (-double-)) v) #{ glTexCoord3dv(IDX_PTR($v,double)); #} ())
(de glTexCoord3fv(v) ((-idx1- (-float-) ) v) #{ glTexCoord3fv(IDX_PTR($v,float)); #} ())
(de glTexCoord3iv(v) ((-idx1- (-int-)   ) v) #{ glTexCoord3iv(IDX_PTR($v,int)); #} ())
(de glTexCoord3sv(v) ((-idx1- (-short-) ) v) #{ glTexCoord3sv(IDX_PTR($v,short)); #} ())

(de glTexCoord4dv(v) ((-idx1- (-double-)) v) #{ glTexCoord4dv(IDX_PTR($v,double)); #} ())
(de glTexCoord4fv(v) ((-idx1- (-float-) ) v) #{ glTexCoord4fv(IDX_PTR($v,float)); #} ())
(de glTexCoord4iv(v) ((-idx1- (-int-)   ) v) #{ glTexCoord4iv(IDX_PTR($v,int)); #} ())
(de glTexCoord4sv(v) ((-idx1- (-short-) ) v) #{ glTexCoord4sv(IDX_PTR($v,short)); #} ())

(de glRasterPos2d(x y) ((GLdouble) x y) #{ glRasterPos2d($x,$y); #} ())
(de glRasterPos2f(x y) ((GLfloat)  x y) #{ glRasterPos2f($x,$y); #} ())
(de glRasterPos2i(x y) ((GLint)    x y) #{ glRasterPos2i($x,$y); #} ())
(de glRasterPos2s(x y) ((GLshort)  x y) #{ glRasterPos2s($x,$y); #} ())

(de glRasterPos3d(x y z) ((GLdouble) x y z) #{ glRasterPos3d($x,$y,$z); #} ())
(de glRasterPos3f(x y z) ((GLfloat)  x y z) #{ glRasterPos3f($x,$y,$z); #} ())
(de glRasterPos3i(x y z) ((GLint)    x y z) #{ glRasterPos3i($x,$y,$z); #} ())
(de glRasterPos3s(x y z) ((GLshort)  x y z) #{ glRasterPos3s($x,$y,$z); #} ())

(de glRasterPos4d(x y z w)((GLdouble) x y z w) #{ glRasterPos4d($x,$y,$z,$w); #} ())
(de glRasterPos4f(x y z w)((GLfloat)  x y z w) #{ glRasterPos4f($x,$y,$z,$w); #} ())
(de glRasterPos4i(x y z w)((GLint)    x y z w) #{ glRasterPos4i($x,$y,$z,$w); #} ())
(de glRasterPos4s(x y z w)((GLshort)  x y z w) #{ glRasterPos4s($x,$y,$z,$w); #} ())

(de glRasterPos2dv(v) ((-idx1- (-double-)) v) 
    #{ glRasterPos2dv(IDX_PTR($v,double)); #} ())
(de glRasterPos2fv(v) ((-idx1- (-float-)) v) 
    #{ glRasterPos2fv(IDX_PTR($v,float)); #} ())
(de glRasterPos2iv(v) ((-idx1- (-int-)) v) 
    #{ glRasterPos2iv(IDX_PTR($v,int)); #} ())
(de glRasterPos2sv(v) ((-idx1- (-short-)) v) 
    #{ glRasterPos2sv(IDX_PTR($v,short)); #} ())

(de glRasterPos3dv(v) ((-idx1- (-double-)) v) 
    #{ glRasterPos3dv(IDX_PTR($v,double)); #} ())
(de glRasterPos3fv(v) ((-idx1- (-float-)) v) 
    #{ glRasterPos3fv(IDX_PTR($v,float)); #} ())
(de glRasterPos3iv(v) ((-idx1- (-int-)) v) 
    #{ glRasterPos3iv(IDX_PTR($v,int)); #} ())
(de glRasterPos3sv(v) ((-idx1- (-short-)) v) 
    #{ glRasterPos3sv(IDX_PTR($v,short)); #} ())

(de glRasterPos4dv(v) ((-idx1- (-double-)) v) 
    #{ glRasterPos4dv(IDX_PTR($v,double)); #} ())
(de glRasterPos4fv(v) ((-idx1- (-float-)) v) 
    #{ glRasterPos4fv(IDX_PTR($v,float)); #} ())
(de glRasterPos4iv(v) ((-idx1- (-int-)) v) 
    #{ glRasterPos4iv(IDX_PTR($v,int)); #} ())
(de glRasterPos4sv(v) ((-idx1- (-short-)) v) 
    #{ glRasterPos4sv(IDX_PTR($v,short)); #} ())

(de glRectd(x1 y1 x2 y2)((GLdouble) x1 y1 x2 y2) #{ glRectd($x1,$y1,$x2,$y2); #}())
(de glRectf(x1 y1 x2 y2)((GLfloat)  x1 y1 x2 y2) #{ glRectf($x1,$y1,$x2,$y2); #}())
(de glRecti(x1 y1 x2 y2)((GLint)    x1 y1 x2 y2) #{ glRecti($x1,$y1,$x2,$y2); #}())
(de glRects(x1 y1 x2 y2)((GLshort)  x1 y1 x2 y2) #{ glRects($x1,$y1,$x2,$y2); #}())

(de glRectdv(v1 v2)
    ((-idx1- (-double-)) v1 v2) 
    #{ glRectdv(IDX_PTR($v1,double),IDX_PTR($v2,double)); #}())
(de glRectfv(v1 v2)
    ((-idx1- (-float-))  v1 v2) 
    #{ glRectfv(IDX_PTR($v1,float),IDX_PTR($v2,float)); #}())
(de glRectiv(v1 v2)
    ((-idx1- (-int-))    v1 v2) 
    #{ glRectiv(IDX_PTR($v1,int),IDX_PTR($v2,int)); #}())
(de glRectsv(v1 v2)
    ((-idx1- (-short-))  v1 v2) 
    #{ glRectsv(IDX_PTR($v1,short),IDX_PTR($v2,short)); #}())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lighting

(de glShadeModel(mode) ((GLenum) mode) #{ glShadeModel($mode); #} ())

(de glLightf(light pname param)
    ((GLenum) light pname)
    ((GLfloat) param)
    #{ glLightf($light,$pname,$param); #} ())
(de glLighti(light pname param)
    ((GLenum) light pname)
    ((GLint) param)
    #{ glLighti($light,$pname,$param); #} ())
(de glLightfv(light pname param)
    ((GLenum) light pname)
    ((-idx1- (-float-)) param)
    #{ glLightfv($light,$pname,IDX_PTR($param,float)); #} ())
(de glLightiv(light pname param)
    ((GLenum) light pname)
    ((-idx1- (-int-)) param)
    #{ glLightiv($light,$pname,IDX_PTR($param,int)); #} ())
(de glGetLightfv(light pname param)
    ((GLenum) light pname)
    ((-idx1- (-float-)) param)
    #{ glGetLightfv($light,$pname,IDX_PTR($param,float)); #} ())
(de glGetLightiv(light pname param)
    ((GLenum) light pname)
    ((-idx1- (-int-)) param)
    #{ glGetLightiv($light,$pname,IDX_PTR($param,int)); #} ())

(de glLightModelf(pname param)
    ((GLenum) pname)
    ((GLfloat) param)
    #{ glLightModelf($pname,$param); #} ())
(de glLightModeli(pname param)
    ((GLenum) pname)
    ((GLint) param)
    #{ glLightModeli($pname,$param); #} ())
(de glLightModelfv(pname param)
    ((GLenum) pname)
    ((-idx1- (-float-)) param)
    #{ glLightModelfv($pname,IDX_PTR($param,float)); #} ())
(de glLightModeliv(pname param)
    ((GLenum) pname)
    ((-idx1- (-int-)) param)
    #{ glLightModeliv($pname,IDX_PTR($param,int)); #} ())

(de glMaterialf( face pname param )
    ((GLenum) face pname)
    ((GLfloat) param)
    #{ glMaterialf( $face, $pname, $param ); #} ())
(de glMateriali( face pname param )
    ((GLenum) face pname)
    ((GLint) param)
    #{ glMateriali( $face, $pname, $param ); #} ())
(de glMaterialfv( face pname param )
    ((GLenum) face pname)
    ((-idx1- (-float-)) param)
    #{ glMaterialfv( $face, $pname, IDX_PTR($param,float) ); #} ())
(de glMaterialiv( face pname param )
    ((GLenum) face pname)
    ((-idx1- (-int-)) param)
    #{ glMaterialiv( $face, $pname, IDX_PTR($param,int) ); #} ())

(de glGetMaterialfv( face pname param )
    ((GLenum) face pname)
    ((-idx1- (-float-)) param)
    #{ glGetMaterialfv( $face, $pname, IDX_PTR($param,float) ); #} ())
(de glGetMaterialiv( face pname param )
    ((GLenum) face pname)
    ((-idx1- (-int-)) param)
    #{ glGetMaterialiv( $face, $pname, IDX_PTR($param,int) ); #} ())

(de glColorMaterial( face mode )
    ((GLenum) face mode )
    #{ glColorMaterial( $face, $mode ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Raster functions

(de glPixelZoom( xfactor yfactor )
    ((GLfloat) xfactor yfactor )
    #{ glPixelZoom( $xfactor, $yfactor ); #} ())


(de glPixelStoref( pname param )
    ((GLenum) pname)
    ((GLfloat) param)
    #{ glPixelStoref( $pname, $param ); #} ())
(de glPixelStorei( pname param )
    ((GLenum) pname)
    ((GLint) param)
    #{ glPixelStorei( $pname, $param ); #} ())

(de glPixelTransferf( pname param )
    ((GLenum) pname)
    ((GLfloat) param)
    #{ glPixelTransferf( $pname, $param ); #} ())
(de glPixelTransferi( pname param )
    ((GLenum) pname)
    ((GLint) param)
    #{ glPixelTransferi( $pname, $param ); #} ())

(de glPixelMapfv( map mapsize values )
    ((GLenum) map)
    ((GLint) mapsize)
    ((-idx1- (-float-)) values)
    #{ glPixelMapfv( $map, $mapsize, IDX_PTR($values,float) ); #} ())
(de glPixelMapuiv( map mapsize values )
    ((GLenum) map)
    ((GLint) mapsize)
    ((-idx1- (-int-)) values)
    #{ glPixelMapuiv( $map, $mapsize, IDX_PTR($values,unsigned int) ); #} ())
(de glPixelMapusv( map mapsize values )
    ((GLenum) map)
    ((GLint) mapsize)
    ((-idx1- (-short-)) values)
    #{ glPixelMapusv( $map, $mapsize, IDX_PTR($values,unsigned short) ); #} ())


(de glGetPixelMapfv( map values )
    ((GLenum) map)
    ((-idx1- (-float-)) values)
    #{ glGetPixelMapfv( $map, IDX_PTR($values,float) ); #} ())
(de glGetPixelMapuiv( map values )
    ((GLenum) map)
    ((-idx1- (-int-)) values)
    #{ glGetPixelMapuiv( $map, IDX_PTR($values,unsigned int) ); #} ())
(de glGetPixelMapusv( map values )
    ((GLenum) map)
    ((-idx1- (-int-)) values)
    #{ glGetPixelMapusv( $map, IDX_PTR($values,unsigned short) ); #} ())

(de glBitmap(width height xorig yorig xmove ymove bitmap )
    ((GLsizei) width height)
    ((GLfloat) xorig yorig xmove ymove)
    ((-idx1- (-ubyte-)) bitmap)
    #{ glBitmap( $width, $height, $xorig, $yorig, $xmove, $ymove, IDX_PTR($bitmap, unsigned char )); #} ())

(de glReadPixels( x y width height format type pixels )
    ((GLint) x y)
    ((GLsizei) width height)
    ((GLenum) format type)
    ((-gptr-) pixels)
    #{ glReadPixels( $x, $y, $width, $height, $format, $type, $pixels ); #} ())

(de glDrawPixels( width height format type pixels )
    ((GLsizei) width height)
    ((GLenum) format type)
    ((-gptr-) pixels)
    #{ glDrawPixels( $width, $height, $format, $type, $pixels ); #} ())

(de glCopyPixels( x y width height type )
    ((GLint) x y)
    ((GLsizei) width height)
    ((GLenum) type)
    #{ glCopyPixels( $x, $y, $width, $height, $type ); #} ())


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stenciling

(de glStencilFunc( func ref mask )
    ((GLenum) func)
    ((GLint) ref)
    ((GLuint) mask)
    #{ glStencilFunc(  $func, $ref, $mask ); #} ())

(de glStencilMask( mask )
    ((GLuint) mask )
    #{ glStencilMask( $mask ); #} ())

(de glStencilOp(  fail zfail zpass )
    ((GLenum) fail zfail zpass )
    #{ glStencilOp(  $fail, $zfail, $zpass ); #} ())

(de glClearStencil( s )
    ((GLint) s)
    #{ glClearStencil( $s ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Texture mapping

(de glTexGend( coord pname param )
    ((GLenum) coord pname)
    ((GLdouble) param)
    #{ glTexGend( $coord, $pname, $param ); #} ())
(de glTexGenf( coord pname param )
    ((GLenum) coord pname)
    ((GLfloat) param)
    #{ glTexGenf( $coord, $pname, $param ); #} ())
(de glTexGeni( coord pname param )
    ((GLenum) coord pname)
    ((GLint) param)
    #{ glTexGeni( $coord, $pname, $param ); #} ())

(de glTexGendv( coord pname param )
    ((GLenum) coord pname)
    ((-idx1- (-double-)) param)
    #{ glTexGendv( $coord, $pname, IDX_PTR($param,double) ); #} ())
(de glTexGenfv( coord pname param )
    ((GLenum) coord pname)
    ((-idx1- (-float-)) param)
    #{ glTexGenfv( $coord, $pname, IDX_PTR($param,float) ); #} ())
(de glTexGeniv( coord pname param )
    ((GLenum) coord pname)
    ((-idx1- (-int-)) param)
    #{ glTexGeniv( $coord, $pname, IDX_PTR($param,int) ); #} ())

(de glGetTexGendv( coord pname param )
    ((GLenum) coord pname)
    ((-idx1- (-double-)) param)
    #{ glGetTexGendv( $coord, $pname, IDX_PTR($param,double) ); #} ())
(de glGetTexGenfv( coord pname param )
    ((GLenum) coord pname)
    ((-idx1- (-float-)) param)
    #{ glGetTexGenfv( $coord, $pname, IDX_PTR($param,float) ); #} ())
(de glGetTexGeniv( coord pname param )
    ((GLenum) coord pname)
    ((-idx1- (-int-)) param)
    #{ glGetTexGeniv( $coord, $pname, IDX_PTR($param,int) ); #} ())


(de glTexEnvf( target pname param )
    ((GLenum) target pname)
    ((GLfloat) param)
    #{ glTexEnvf( $target, $pname, $param ); #} ())
(de glTexEnvi( target pname param )
    ((GLenum) target pname)
    ((GLint) param)
    #{ glTexEnvi( $target, $pname, $param ); #} ())

(de glTexEnvfv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-float-)) param)
    #{ glTexEnvfv( $target, $pname, IDX_PTR($param,float) ); #} ())
(de glTexEnviv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-int-)) param)
    #{ glTexEnviv( $target, $pname, IDX_PTR($param,int) ); #} ())

(de glGetTexEnvfv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-float-)) param)
    #{ glGetTexEnvfv( $target, $pname, IDX_PTR($param,float) ); #} ())
(de glGetTexEnviv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-int-)) param)
    #{ glGetTexEnviv( $target, $pname, IDX_PTR($param,int) ); #} ())

(de glTexParameterf( target pname param )
    ((GLenum) target pname)
    ((GLfloat) param)
    #{ glTexParameterf( $target, $pname, $param ); #} ())
(de glTexParameteri( target pname param )
    ((GLenum) target pname)
    ((GLint) param)
    #{ glTexParameteri( $target, $pname, $param ); #} ())

(de glTexParameterfv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-float-)) param)
    #{ glTexParameterfv( $target, $pname, IDX_PTR($param,float) ); #} ())
(de glTexParameteriv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-int-)) param)
    #{ glTexParameteriv( $target, $pname, IDX_PTR($param,int) ); #} ())

(de glGetTexParameterfv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-float-)) param)
    #{ glGetTexParameterfv( $target, $pname, IDX_PTR($param,float) ); #} ())
(de glGetTexParameteriv( target pname param )
    ((GLenum) target pname)
    ((-idx1- (-int-)) param)
    #{ glGetTexParameteriv( $target, $pname, IDX_PTR($param,int) ); #} ())

(de glGetTexLevelParameterfv( target level pname params )
    ((GLenum) target pname)
    ((GLint) level)
    ((-idx1- (-float-)) params)
    #{ glGetTexLevelParameterfv($target,$level,$pname,IDX_PTR($params,float)); #} ())
(de glGetTexLevelParameteriv( target level pname params )
    ((GLenum) target pname)
    ((GLint) level)
    ((-idx1- (-int-)) params)
    #{ glGetTexLevelParameteriv($target,$level,$pname,IDX_PTR($params,int)); #} ())

(de glTexImage1D( target level components width border format type pixels )
    ((GLenum) target format type)
    ((GLint) level components border)
    ((GLsizei) width)
    ((-gptr-) pixels)
    #{ glTexImage1D( $target,$level,$components,$width,$border,$format,$type,$pixels ); #} ())
(de glTexImage2D( target level components width height border format type pixels )
    ((GLenum) target format type)
    ((GLint) level components border)
    ((GLsizei) width height)
    ((-gptr-) pixels)
    #{ glTexImage2D( $target,$level,$components,$width,$height,$border,$format,$type,$pixels ); #} ())
(de glGetTexImage( target level format type pixels )
    ((GLenum) target format type)
    ((GLint) level )
    ((-gptr-) pixels)
    #{ glGetTexImage( $target,$level,$format,$type,$pixels ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Evaluators

(de glMap1d( target u1 u2 stride order points )
    ((GLenum) target)
    ((GLdouble) u1 u2)
    ((GLint) stride order)
    ((-idx1- (-double-)) points)
    #{ glMap1d( $target,$u1, $u2, $stride, $order, IDX_PTR($points,double) ); #} ())
(de glMap1f( target u1 u2 stride order points )
    ((GLenum) target)
    ((GLfloat) u1 u2)
    ((GLint) stride order)
    ((-idx1- (-float-)) points)
    #{ glMap1f( $target,$u1, $u2, $stride, $order, IDX_PTR($points,float) ); #} ())

(de glMap2d( target u1 u2 ustride uorder v1 v2 vstride vorder points )
    ((GLenum) target)
    ((GLdouble) u1 u2 v1 v2)
    ((GLint) ustride uorder vstride vorder)
    ((-idx1- (-double-)) points)
    #{ glMap2d( $target,$u1,$u2,$ustride,$uorder,$v1,$v2,$vstride,$vorder,IDX_PTR($points,double) ); #} ())
(de glMap2f( target u1 u2 ustride uorder v1 v2 vstride vorder points )
    ((GLenum) target)
    ((GLfloat) u1 u2 v1 v2)
    ((GLint) ustride uorder vstride vorder)
    ((-idx1- (-float-)) points)
    #{ glMap2f( $target,$u1,$u2,$ustride,$uorder,$v1,$v2,$vstride,$vorder,IDX_PTR($points,float) ); #} ())

(de glGetMapdv( target query v )
    ((GLenum) target query)
    ((-idx1- (-double-)) v )
    #{ glGetMapdv( $target, $query, IDX_PTR($v,double) ); #} ())
(de glGetMapfv( target query v )
    ((GLenum) target query)
    ((-idx1- (-float-)) v )
    #{ glGetMapfv( $target, $query, IDX_PTR($v,float) ); #} ())
(de glGetMapiv( target query v )
    ((GLenum) target query)
    ((-idx1- (-int-)) v )
    #{ glGetMapiv( $target, $query, IDX_PTR($v,int) ); #} ())

(de glEvalCoord1d( u )
    ((GLdouble) u )
    #{ glEvalCoord1d( $u ); #} ())
(de glEvalCoord1f( u )
    ((GLfloat) u )
    #{ glEvalCoord1f( $u ); #} ())

(de glEvalCoord1dv( u )
    ((-idx1- (-double-)) u )
    #{ glEvalCoord1dv( IDX_PTR($u,double) ); #} ())
(de glEvalCoord1fv( u )
    ((-idx1- (-float-)) u )
    #{ glEvalCoord1fv( IDX_PTR($u,float) ); #} ())

(de glEvalCoord2d( u v)
    ((GLdouble) u v)
    #{ glEvalCoord2d( $u,$v ); #} ())
(de glEvalCoord2f( u v)
    ((GLfloat) u v)
    #{ glEvalCoord2f( $u,$v ); #} ())

(de glEvalCoord2dv( u )
    ((-idx2- (-double-)) u )
    #{ glEvalCoord2dv( IDX_PTR($u,double) ); #} ())
(de glEvalCoord2fv( u )
    ((-idx2- (-float-)) u )
    #{ glEvalCoord2fv( IDX_PTR($u,float) ); #} ())

(de glMapGrid1d( un u1 u2 )
    ((GLint) un)
    ((GLdouble) u1 u2 )
    #{ glMapGrid1d( $un, $u1, $u2 ); #} ())
(de glMapGrid1f( un u1 u2 )
    ((GLint) un)
    ((GLfloat) u1 u2 )
    #{ glMapGrid1f( $un, $u1, $u2 ); #} ())

(de glMapGrid2d( un u1 u2 vn v1 v2 )
    ((GLint) un vn)
    ((GLdouble) u1 u2 v1 v2)
    #{ glMapGrid2d( $un, $u1, $u2, $vn, $v1, $v2 ); #} ())
(de glMapGrid2f( un u1 u2 vn v1 v2 )
    ((GLint) un vn)
    ((GLfloat) u1 u2 v1 v2)
    #{ glMapGrid2f( $un, $u1, $u2, $vn, $v1, $v2 ); #} ())

(de glEvalPoint1( i )
    ((GLint) i )
    #{ glEvalPoint1( $i ); #} ())

(de glEvalPoint2( i j )
    ((GLint) i j)
    #{ glEvalPoint2( $i, $j ); #} ())

(de glEvalMesh1( mode i1 i2 )
    ((GLenum) mode)
    ((GLint) i1 i2 )
    #{ glEvalMesh1( $mode, $i1, $i2 ); #} ())

(de glEvalMesh2(  mode i1 i2 j1 j2 )
    ((GLenum) mode)
    ((GLint) i1 i2 j1 j2)
    #{ glEvalMesh2( $mode, $i1, $i2, $j1, $j2 ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Fog

(de glFogf( pname param )
    ((GLenum) pname)
    ((GLfloat) param )
    #{ glFogf( $pname, $param ); #} ())
(de glFogi( pname param )
    ((GLenum) pname)
    ((GLint) param )
    #{ glFogi( $pname, $param ); #} ())

(de glFogfv( pname param )
    ((GLenum) pname)
    ((-idx1- (-float-)) param )
    #{ glFogfv( $pname, IDX_PTR($param,float) ); #} ())
(de glFogiv( pname param )
    ((GLenum) pname)
    ((-idx1- (-int-)) param )
    #{ glFogiv( $pname, IDX_PTR($param,int) ); #} ())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Selection and Feedback

(de glFeedbackBuffer(  size type buffer )
    ((GLsizei) size)
    ((GLenum) type)
    ((-idx1- (-float-)) buffer)
    #{ glFeedbackBuffer( $size, $type, IDX_PTR($buffer,float) ); #} ())

(de glPassThrough( token )
    ((GLfloat) token )
    #{ glPassThrough( $token ); #} ())

(de glSelectBuffer( size buffer )
    ((GLsizei) size)
    ((-idx1- (-int-)) buffer)
    #{ glSelectBuffer( $size, IDX_PTR($buffer,unsigned int) ); #} ())

(de glInitNames() #{ glInitNames(); #} ())

(de glLoadName( name ) ((GLuint) name) #{ glLoadName( $name ); #} ())

(de glPushName( name ) ((GLuint) name) #{ glPushName( $name ); #} ())

(de glPopName() #{ glPopName(); #} ())


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar glfunclist '("glClearIndex" "glClearColor" "glClear" "glIndexMask"
   "glColorMask" "glAlphaFunc" "glBlendFunc" "glLogicOp" "glCullFace"
   "glFrontFace" "glPointSize" "glLineWidth" "glLineStipple" "glPolygonMode"
   "glPolygonStipple" "glGetPolygonStipple" "glEdgeFlag" "glEdgeFlagv"
   "glScissor" "glClipPlane" "glGetClipPlane" "glDrawBuffer" "glReadBuffer"
   "glEnable" "glDisable" "glIsEnabled" "glGetBooleanv" "glGetDoublev"
   "glGetFloatv" "glGetIntegerv" "glPushAttrib" "glPopAttrib" "glRenderMode"
   "glGetError" "glGetString" "glFinish" "glFlush" "glHint" "glClearDepth"
   "glDepthFunc" "glDepthMask" "glDepthRange" "glClearAccum" "glAccum"
   "glMatrixMode" "glOrtho" "glFrustum" "glViewport" "glPushMatrix"
   "glPopMatrix" "glLoadIdentity" "glLoadMatrixd" "glLoadMatrixf"
   "glMultMatrixd" "glMultMatrixf" "glRotated" "glRotatef" "glScaled"
   "glScalef" "glTranslated" "glTranslatef" "glIsList" "glDeleteLists"
   "glGenLists" "glNewList" "glEndList" "glCallList" "glCallLists"
   "glListBase" "glBegin" "glEnd" "glVertex2d" "glVertex2f" "glVertex2i"
   "glVertex2s" "glVertex3d" "glVertex3f" "glVertex3i" "glVertex3s"
   "glVertex4d" "glVertex4f" "glVertex4i" "glVertex4s" "glVertex2dv"
   "glVertex2fv" "glVertex2iv" "glVertex2sv" "glVertex3dv" "glVertex3fv"
   "glVertex3iv" "glVertex3sv" "glVertex4dv" "glVertex4fv" "glVertex4iv"
   "glVertex4sv" "glNormal3b" "glNormal3d" "glNormal3f" "glNormal3i"
   "glNormal3s" "glNormal3bv" "glNormal3dv" "glNormal3fv" "glNormal3iv"
   "glNormal3sv" "glIndexd" "glIndexf" "glIndexi" "glIndexs" "glIndexdv"
   "glIndexfv" "glIndexiv" "glIndexsv" "glColor3b" "glColor3d" "glColor3f"
   "glColor3i" "glColor3s" "glColor3ub" "glColor3ui" "glColor3us" "glColor4b"
   "glColor4d" "glColor4f" "glColor4i" "glColor4s" "glColor4ub" "glColor4ui"
   "glColor4us" "glColor3bv" "glColor3dv" "glColor3fv" "glColor3iv"
   "glColor3sv" "glColor3ubv" "glColor3uiv" "glColor3usv" "glColor4bv"
   "glColor4dv" "glColor4fv" "glColor4iv" "glColor4sv" "glColor4ubv"
   "glColor4uiv" "glColor4usv" "glTexCoord1d" "glTexCoord1f" "glTexCoord1i"
   "glTexCoord1s" "glTexCoord2d" "glTexCoord2f" "glTexCoord2i" "glTexCoord2s"
   "glTexCoord3d" "glTexCoord3f" "glTexCoord3i" "glTexCoord3s" "glTexCoord4d"
   "glTexCoord4f" "glTexCoord4i" "glTexCoord4s" "glTexCoord1dv"
   "glTexCoord1fv" "glTexCoord1iv" "glTexCoord1sv" "glTexCoord2dv"
   "glTexCoord2fv" "glTexCoord2iv" "glTexCoord2sv" "glTexCoord3dv"
   "glTexCoord3fv" "glTexCoord3iv" "glTexCoord3sv" "glTexCoord4dv"
   "glTexCoord4fv" "glTexCoord4iv" "glTexCoord4sv" "glRasterPos2d"
   "glRasterPos2f" "glRasterPos2i" "glRasterPos2s" "glRasterPos3d"
   "glRasterPos3f" "glRasterPos3i" "glRasterPos3s" "glRasterPos4d"
   "glRasterPos4f" "glRasterPos4i" "glRasterPos4s" "glRasterPos2dv"
   "glRasterPos2fv" "glRasterPos2iv" "glRasterPos2sv" "glRasterPos3dv"
   "glRasterPos3fv" "glRasterPos3iv" "glRasterPos3sv" "glRasterPos4dv"
   "glRasterPos4fv" "glRasterPos4iv" "glRasterPos4sv" "glRectd" "glRectf"
   "glRecti" "glRects" "glRectdv" "glRectfv" "glRectiv" "glRectsv"
   "glShadeModel" "glLightf" "glLighti" "glLightfv" "glLightiv" "glGetLightfv"
   "glGetLightiv" "glLightModelf" "glLightModeli" "glLightModelfv"
   "glLightModeliv" "glMaterialf" "glMateriali" "glMaterialfv" "glMaterialiv"
   "glGetMaterialfv" "glGetMaterialiv" "glColorMaterial" "glPixelZoom"
   "glPixelStoref" "glPixelStorei" "glPixelTransferf" "glPixelTransferi"
   "glPixelMapfv" "glPixelMapuiv" "glPixelMapusv" "glGetPixelMapfv"
   "glGetPixelMapuiv" "glGetPixelMapusv" "glBitmap" "glReadPixels"
   "glDrawPixels" "glCopyPixels" "glStencilFunc" "glStencilMask" "glStencilOp"
   "glClearStencil" "glTexGend" "glTexGenf" "glTexGeni" "glTexGendv"
   "glTexGenfv" "glTexGeniv" "glGetTexGendv" "glGetTexGenfv" "glGetTexGeniv"
   "glTexEnvf" "glTexEnvi" "glTexEnvfv" "glTexEnviv" "glGetTexEnvfv"
   "glGetTexEnviv" "glTexParameterf" "glTexParameteri" "glTexParameterfv"
   "glTexParameteriv" "glGetTexParameterfv" "glGetTexParameteriv"
   "glGetTexLevelParameterfv" "glGetTexLevelParameteriv" "glTexImage1D"
   "glTexImage2D" "glGetTexImage" "glMap1d" "glMap1f" "glMap2d" "glMap2f"
   "glGetMapdv" "glGetMapfv" "glGetMapiv" "glEvalCoord1d" "glEvalCoord1f"
   "glEvalCoord1dv" "glEvalCoord1fv" "glEvalCoord2d" "glEvalCoord2f"
   "glEvalCoord2dv" "glEvalCoord2fv" "glMapGrid1d" "glMapGrid1f" "glMapGrid2d"
   "glMapGrid2f" "glEvalPoint1" "glEvalPoint2" "glEvalMesh1" "glEvalMesh2"
   "glFogf" "glFogi" "glFogfv" "glFogiv" "glFeedbackBuffer" "glPassThrough"
   "glSelectBuffer" "glInitNames" "glLoadName" "glPushName" "glPopName" ))


(let ((dhc-make-lushflags (concat dhc-make-lushflags opengl-cflags)))
  (dhc-make-all ()
                (mapcar named (mapcar downcase glfunclist))
                (list opengl-libgl opengl-libglu) ) )


