;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; 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: openglu.lsh,v 1.4 2004/01/18 05:15:52 leonb Exp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


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


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; OpenGLU interface
;; This is done from the glu.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.



(de gluBeginCurve (nurb)
    ((-gptr- "GLUnurbs*") nurb)
    (cheader "#include <GL/glu.h>")
    #{ gluBeginCurve ($nurb); #} ())
(de gluBeginPolygon (tess)
    ((-gptr- "GLUtesselator*") tess)
    #{ gluBeginPolygon ($tess); #} ())
(de gluBeginSurface (nurb)
    ((-gptr- "GLUnurbs*") nurb)
    #{ gluBeginSurface ($nurb); #} ())
(de gluBeginTrim (nurb)
    ((-gptr- "GLUnurbs*") nurb)
    #{ gluBeginTrim ($nurb); #} ())
(de gluBuild1DMipmaps (target component width format type data)
    ((GLenum) target)
    ((GLint) component)
    ((GLsizei) width)
    ((GLenum) format)
    ((GLenum) type)
    ((-gptr-) data)
    #{  gluBuild1DMipmaps ($target, $component, $width, $format, $type, $data); #} ())
(de gluBuild2DMipmaps (target component width height format type data)
    ((GLenum) target)
    ((GLint) component)
    ((GLsizei) width height)
    ((GLenum) format)
    ((GLenum) type)
    ((-gptr-) data)
    #{  gluBuild2DMipmaps ($target, $component, $width, $height, $format, $type, $data); #} ())
(de gluCylinder ( quad base top height slices stacks)
    ((-gptr- "GLUquadric*") quad)
    ((GLdouble) base)
    ((GLdouble) top)
    ((GLdouble) height)
    ((GLint) slices)
    ((GLint) stacks)
    #{ gluCylinder ($quad, $base, $top, $height, $slices, $stacks); #} ())
(de gluDeleteNurbsRenderer (nurb)
    ((-gptr- "GLUnurbs*") nurb)
    #{ gluDeleteNurbsRenderer ($nurb); #} ())
(de gluDeleteQuadric (quad)
    ((-gptr- "GLUquadric*") quad)
    #{ gluDeleteQuadric ($quad); #} ())
(de gluDeleteTess (tess)
    ((-gptr- "GLUtesselator*") tess)
    #{ gluDeleteTess ($tess); #} ())
(de gluDisk ( quad inner outer slices loops)
    ((-gptr- "GLUquadric*") quad)
    ((GLdouble) inner outer)
    ((GLint) slices loops)
    #{ gluDisk ($quad, $inner, $outer, $slices, $loops); #} ())
(de gluEndCurve (nurb)
    ((-gptr- "GLUnurbs*") nurb)
    #{ gluEndCurve ($nurb); #} ())
(de gluEndPolygon (tess)
    ((-gptr- "GLUtesselator*") tess)
    #{ gluEndPolygon ($tess); #} ())
(de gluEndSurface (nurb)
    ((-gptr- "GLUnurbs*") nurb)
    #{ gluEndSurface ($nurb); #} ())
(de gluEndTrim (nurb)
    ((-gptr- "GLUnurbs*") nurb)
    #{ gluEndTrim ($nurb); #} ())
(de gluErrorString (error)
    ((GLenum) error)
    (gptr #{  gluErrorString ($error) #}))
(de gluGetNurbsProperty (nurb property data)
    ((-gptr- "GLUnurbs*") nurb)
    ((GLenum) property)
    ((-idx1- (-float-)) data)
    #{ gluGetNurbsProperty ($nurb, $property, IDX_PTR($data,GLfloat)); #} ())
(de gluGetString (name)
    ((GLenum) name)
    (gptr #{ gluGetString ($name) #}))
(de gluGetTessProperty (tess which data)
    ((-gptr- "GLUtesselator*") tess)
    ((GLenum) which)
    ((-idx1- (-double-)) data)
    #{ gluGetTessProperty ($tess, $which, IDX_PTR($data,GLdouble)); #} ())
(de gluLoadSamplingMatrices (nurb model perspective view)
    ((-gptr- "GLUnurbs*") nurb)
    ((-idx1- (-float-)) model perspective)
    ((-idx1- (-int-)) view)
    #{ gluLoadSamplingMatrices ($nurb, IDX_PTR($model,GLfloat), IDX_PTR($perspective,GLfloat), IDX_PTR($view,GLint)); #} ())
(de gluLookAt ( eyex eyey eyez centerx centery centerz upx upy upz)
    ((GLdouble) eyex eyey eyez centerx centery centerz upx upy upz)
    #{ gluLookAt ($eyex, $eyey, $eyez, $centerx, $centery, $centerz, $upx, $upy, $upz); #} ())
(de gluNewNurbsRenderer () (gptr #{ gluNewNurbsRenderer () #}))
(de gluNewQuadric () (gptr #{ gluNewQuadric () #}))
(de gluNewTess () (gptr #{ gluNewTess () #}))
(de gluNextContour (tess type)
    ((-gptr- "GLUtesselator*") tess)
    ((GLenum) type)
    #{ gluNextContour ($tess, $type); #} ())
(de gluNurbsCallback (nurb which callbackfunc)
    ((-gptr- "GLUnurbs*") nurb)
    ((GLenum) which)
    ((-gptr-) callbackfunc)
    #{ gluNurbsCallback ($nurb, $which, $callbackfunc); #} ())
(de gluNurbsCurve (nurb knotcount knots stride control order type)
    ((-gptr- "GLUnurbs*") nurb)
    ((GLint) knotcount)
    ((-idx1- (-float-)) knots)
    ((GLint) stride)
    ((-idx1- (-float-)) control)
    ((GLint) order)
    ((GLenum) type)
    #{ gluNurbsCurve ($nurb, $knotcount, IDX_PTR($knots,GLfloat), $stride, IDX_PTR($control,GLfloat), $order, $type); #} ())
(de gluNurbsProperty (nurb property value)
    ((-gptr- "GLUnurbs*") nurb)
    ((GLenum) property)
    ((GLfloat) value)
    #{ gluNurbsProperty ($nurb, $property, $value); #} ())
(de gluNurbsSurface (nurb sknotcount sknots tknotcount tknots sstride tstride control sorder torder type)
    ((-gptr- "GLUnurbs*") nurb)
    ((GLint) sknotcount)
    ((-idx1- (-float-)) sknots)
    ((GLint) tknotcount)
    ((-idx1- (-float-)) tknots)
    ((GLint) sstride)
    ((GLint) tstride)
    ((-idx1- (-float-)) control)
    ((GLint) sorder)
    ((GLint) torder)
    ((GLenum) type)
    #{ gluNurbsSurface ($nurb, $sknotcount, IDX_PTR($sknots,GLfloat), $tknotcount, IDX_PTR($tknots,GLfloat), $sstride, $tstride, IDX_PTR($control,GLfloat), $sorder, $torder, $type); #} ())
(de gluOrtho2D ( left right bottom top)
    ((GLdouble) left right bottom top)
    #{ gluOrtho2D ($left, $right, $bottom, $top); #} ())
(de gluPartialDisk ( quad inner outer slices loops start sweep)
    ((-gptr- "GLUquadric*") quad)
    ((GLdouble) inner outer)
    ((GLint) slices loops)
    ((GLdouble) start sweep)
    #{ gluPartialDisk ($quad, $inner, $outer, $slices, $loops, $start, $sweep); #} ())
(de gluPerspective ( fovy aspect znear zfar)
    ((GLdouble) fovy aspect znear zfar)
    #{ gluPerspective ($fovy, $aspect, $znear, $zfar); #} ())
(de gluPickMatrix ( x y delx dely viewport)
    ((GLdouble) x y delx dely)
    ((-idx1- (-int-)) viewport)
    #{ gluPickMatrix ($x, $y, $delx, $dely, IDX_PTR($viewport,int)); #} ())
(de gluProject ( objx objy objz model proj view winx winy winz)
    ((GLdouble) objx objy objz)
    ((-idx1- (-double-)) model proj)
    ((-idx1- (-int-)) view)
    ((-idx1- (-double-)) winx winy winz)
    #{ gluProject ($objx, $objy, $objz, IDX_PTR($model,double), IDX_PTR($proj,double), IDX_PTR($view,int), IDX_PTR($winx,double), IDX_PTR($winy,double), IDX_PTR($winz,double)); #} ())
(de gluPwlCurve ( nurb count data stride type)
    ((-gptr- "GLUnurbs*") nurb)
    ((GLint) count)
    ((-idx1- (-float-)) data)
    ((GLint) stride)
    ((GLenum) type)
    #{ gluPwlCurve ($nurb, $count, IDX_PTR($data,float), $stride, $type); #} ())
(de gluQuadricCallback (quad which callbackfunc)
    ((-gptr- "GLUquadric*") quad)
    ((GLenum) which)
    ((-gptr-) callbackfunc)
    #{  gluQuadricCallback ($quad, $which, $callbackfunc); #} ())
(de gluQuadricDrawStyle (quad draw)
    ((-gptr- "GLUquadric*") quad)
    ((GLenum) draw)
    #{ gluQuadricDrawStyle ($quad, $draw); #} ())
(de gluQuadricNormals ( quad normal)
    ((-gptr- "GLUquadric*") quad)
    ((GLenum) normal)
    #{ gluQuadricNormals ($quad, $normal); #} ())
(de gluQuadricOrientation ( quad orientation)
    ((-gptr- "GLUquadric*") quad)
    ((GLenum) orientation)
    #{ gluQuadricOrientation ($quad, $orientation); #} ())
(de gluQuadricTexture ( quad texture)
    ((-gptr- "GLUquadric*") quad)
    ((GLboolean) texture)
    #{ gluQuadricTexture ($quad, $texture); #} ())
(de gluScaleImage ( format win hin typein datain wout hout typeout dataout)
    ((GLenum) format)
    ((GLsizei) win hin)
    ((GLenum) typein)
    ((-gptr-) datain)
    ((GLsizei) wout hout)
    ((GLenum) typeout)
    ((-gptr-) dataout)
    (int #{ gluScaleImage ($format, $win, $hin, $typein, $datain, $wout, $hout, $typeout, $dataout) #}))
(de gluSphere ( quad radius slices stacks)
    ((-gptr- "GLUquadric*") quad)
    ((GLdouble) radius)
    ((GLint) slices stacks)
    #{ gluSphere ($quad, $radius, $slices, $stacks); #} ())
(de gluTessBeginContour (tess)
    ((-gptr- "GLUtesselator*") tess)
    #{ gluTessBeginContour ($tess); #} ())
(de gluTessBeginPolygon (tess data)
    ((-gptr- "GLUtesselator*") tess)
    ((-gptr-) data)
    #{ gluTessBeginPolygon ($tess, $data); #} ())
(de gluTessCallback (tess which callbackfunc)
    ((-gptr- "GLUtesselator*") tess)
    ((GLenum) which)
    ((-gptr-) callbackfunc)
    #{ gluTessCallback ($tess, $which, $callbackfunc); #} ())
(de gluTessEndContour (tess)
    ((-gptr- "GLUtesselator*") tess)
    #{ gluTessEndContour ($tess); #} ())
(de gluTessEndPolygon (tess)
    ((-gptr- "GLUtesselator*") tess)
    #{ gluTessEndPolygon ($tess); #} ())
(de gluTessNormal (tess valuex valuey valuez)
    ((-gptr- "GLUtesselator*") tess)
    ((GLdouble) valuex valuey valuez)
    #{ gluTessNormal ($tess, $valuex, $valuey, $valuez); #} ())
(de gluTessProperty (tess which data)
    ((-gptr- "GLUtesselator*") tess)
    ((GLenum) which)
    ((GLdouble) data)
    #{ gluTessProperty ($tess, $which, $data); #} ())
(de gluTessVertex (tess location data)
    ((-gptr- "GLUtesselator*") tess)
    ((-idx1- (-double-)) location)
    ((-gptr-) data)
    #{ gluTessVertex ($tess, IDX_PTR($location,double), $data); #} ())
(de gluUnProject (winx winy winz model proj view objx objy objz)
    ((GLdouble) winx winy winz)
    ((-idx1- (-double-)) model proj)
    ((-idx1- (-int-)) view)
    ((-idx1- (-double-)) objx objy objz)
    (int #{ gluUnProject ($winx, $winy, $winz, IDX_PTR($model,double), IDX_PTR($proj,double), IDX_PTR($view,int), IDX_PTR($objx,double), IDX_PTR($objy,double), IDX_PTR($objz,double)) #}))

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

(defvar glufunclist 
  '("gluBeginCurve" "gluBeginPolygon" "gluBeginSurface"
    "gluBeginTrim" "gluBuild1DMipmaps" "gluBuild2DMipmaps" "gluCylinder"
    "gluDeleteNurbsRenderer" "gluDeleteQuadric" "gluDeleteTess" "gluDisk"
    "gluEndCurve" "gluEndPolygon" "gluEndSurface" "gluEndTrim" "gluErrorString"
    "gluGetNurbsProperty" "gluGetString" "gluGetTessProperty"
    "gluLoadSamplingMatrices" "gluLookAt" "gluNewNurbsRenderer" "gluNewQuadric"
    "gluNewTess" "gluNextContour" "gluNurbsCallback" "gluNurbsCurve"
    "gluNurbsProperty" "gluNurbsSurface" "gluOrtho2D" "gluPartialDisk"
    "gluPerspective" "gluPickMatrix" "gluProject" "gluPwlCurve"
    "gluQuadricCallback" "gluQuadricDrawStyle" "gluQuadricNormals"
    "gluQuadricOrientation" "gluQuadricTexture" "gluScaleImage" "gluSphere"
    "gluTessBeginContour" "gluTessBeginPolygon" "gluTessCallback"
    "gluTessEndContour" "gluTessEndPolygon" "gluTessNormal" "gluTessProperty"
    "gluTessVertex" "gluUnProject"))


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


