]> git.jsancho.org Git - gacela.git/blobdiff - gacela_GL.lisp
(no commit message)
[gacela.git] / gacela_GL.lisp
index bce7813d8351cdf256a815fc210ed3a437e56397..c17b049cc0f8688c232f931390a30565ef1570bc 100644 (file)
 ;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-(in-package :gacela)
+(eval-when (compile load eval)
+          (when (not (find-package 'gacela)) (make-package 'gacela :nicknames '(gg) :use '(lisp)))
+          (in-package 'gacela :nicknames '(gg) :use '(lisp)))
+
+
+(defmacro mapcconst (type c-type name)
+  (let ((c-header (concatenate 'string c-type " gacela_" name " (void)"))
+       (c-body (concatenate 'string "return " name ";"))
+       (c-name (concatenate 'string "gacela_" name))
+       (lisp-name (intern (string-upcase name))))
+    `(progn
+       (defcfun ,c-header 0 ,c-body)
+       (defentry ,lisp-name () (,type ,c-name))
+       (eval-when (load) (defconstant ,lisp-name (,lisp-name))))))
 
 (clines "#include <GL/gl.h>")
 (clines "#include <GL/glu.h>")
 
 ;;; Data types
-(defconstant GL_UNSIGNED_BYTE                 #x1401)
+(mapcconst int "int" "GL_UNSIGNED_BYTE")
 
 ;;; Primitives
-(defconstant GL_POINTS                        #x0000)
-(defconstant GL_LINES                         #x0001)
-(defconstant GL_LINE_LOOP                     #x0002)
-(defconstant GL_LINE_STRIP                    #x0003)
-(defconstant GL_TRIANGLES                     #x0004)
-(defconstant GL_TRIANGLE_STRIP                #x0005)
-(defconstant GL_TRIANGLE_FAN                  #x0006)
-(defconstant GL_QUADS                         #x0007)
-(defconstant GL_QUAD_STRIP                    #x0008)
-(defconstant GL_POLYGON                       #x0009)
+(mapcconst int "int" "GL_POINTS")
+(mapcconst int "int" "GL_LINES")
+(mapcconst int "int" "GL_LINE_LOOP")
+(mapcconst int "int" "GL_LINE_STRIP")
+(mapcconst int "int" "GL_TRIANGLES")
+(mapcconst int "int" "GL_TRIANGLE_STRIP")
+(mapcconst int "int" "GL_TRIANGLE_FAN")
+(mapcconst int "int" "GL_QUADS")
+(mapcconst int "int" "GL_QUAD_STRIP")
+(mapcconst int "int" "GL_POLYGON")
 
 ;;; Matrix Mode
-(defconstant GL_MODELVIEW                     #x1700)
-(defconstant GL_PROJECTION                    #x1701)
+(mapcconst int "int" "GL_MODELVIEW")
+(mapcconst int "int" "GL_PROJECTION")
 
 ;;; Depth buffer
-(defconstant GL_LEQUAL                        #x0203)
-(defconstant GL_DEPTH_TEST                    #x0B71)
+(mapcconst int "int" "GL_LEQUAL")
+(mapcconst int "int" "GL_DEPTH_TEST")
 
 ;;; Lighting
-(defconstant GL_LIGHTING                      #x0B50)
-(defconstant GL_LIGHT1                        #x4001)
-(defconstant GL_AMBIENT                       #x1200)
-(defconstant GL_DIFFUSE                       #x1201)
-(defconstant GL_POSITION                      #x1203)
-(defconstant GL_SMOOTH                        #x1D01)
+(mapcconst int "int" "GL_LIGHTING")
+(mapcconst int "int" "GL_LIGHT1")
+(mapcconst int "int" "GL_AMBIENT")
+(mapcconst int "int" "GL_DIFFUSE")
+(mapcconst int "int" "GL_POSITION")
+(mapcconst int "int" "GL_SMOOTH")
 
 ;;; Blending
-(defconstant GL_BLEND                         #x0BE2)
-(defconstant GL_ONE                           #x1)
-(defconstant GL_SRC_ALPHA                     #x0302)
+(mapcconst int "int" "GL_BLEND")
+(mapcconst int "int" "GL_ONE")
+(mapcconst int "int" "GL_SRC_ALPHA")
 
 ;;; Fog
-(defconstant GL_LINEAR                        #x2601)
+(mapcconst int "int" "GL_LINEAR")
 
 ;;; Buffers, Pixel Drawing/Reading
-(defconstant GL_RGB                           #x1907)
+(mapcconst int "int" "GL_RGB")
+(mapcconst int "int" "GL_RGBA")
 
 ;;; Hints
-(defconstant GL_PERSPECTIVE_CORRECTION_HINT   #x0C50)
-(defconstant GL_NICEST                        #x1102)
+(mapcconst int "int" "GL_PERSPECTIVE_CORRECTION_HINT")
+(mapcconst int "int" "GL_NICEST")
 
 ;;; Texture mapping
-(defconstant GL_TEXTURE_2D                    #x0DE1)
-(defconstant GL_TEXTURE_MAG_FILTER            #x2800)
-(defconstant GL_TEXTURE_MIN_FILTER            #x2801)
-(defconstant GL_LINEAR_MIPMAP_NEAREST         #x2701)
-(defconstant GL_NEAREST                       #x2600)
+(mapcconst int "int" "GL_TEXTURE_2D")
+(mapcconst int "int" "GL_TEXTURE_MAG_FILTER")
+(mapcconst int "int" "GL_TEXTURE_MIN_FILTER")
+(mapcconst int "int" "GL_LINEAR_MIPMAP_NEAREST")
+(mapcconst int "int" "GL_NEAREST")
 
 ;;; glPush/PopAttrib bits
-(defconstant GL_DEPTH_BUFFER_BIT              #x00000100)
-(defconstant GL_COLOR_BUFFER_BIT              #x00004000)
+(mapcconst int "int" "GL_DEPTH_BUFFER_BIT")
+(mapcconst int "int" "GL_COLOR_BUFFER_BIT")
 
 ;;; OpenGL 1.2
-(defconstant GL_BGR                           #x80E0)
+(mapcconst int "int" "GL_BGR")
+(mapcconst int "int" "GL_BGRA")
 
 ;;; OpenGL Functions
 (defcfun "void gacela_glBegin (int mode)" 0
 (defcfun "void gacela_glColor3f (float red, float green, float blue)" 0
   "glColor3f (red, green, blue);")
 
+(defcfun "void gacela_glColor4f (float red, float green, float blue, float alpha)" 0
+  "glColor4f (red, green, blue, alpha);")
+
 (defcfun "void gacela_glDepthFunc (int func)" 0
   "glDepthFunc (func);")
 
   "}"
   "return textures;")
 
+(defcfun "void gacela_glDeleteTextures (int n, object textures)" 0
+  "GLuint text[n];"
+  "int i, t;"
+  "for (i = 0; i < n; i++) {"
+  ((nth (int i) textures) t)
+  "text[i] = t;"
+  "}"
+  "glDeleteTextures (n, &text[0]);")
+
 (defcfun "void gacela_glBindTexture (int target, int texture)" 0
   "glBindTexture (target, texture);")
 
 (defcfun "void gacela_glOrtho (float left, float right, float bottom, float top, float near_val, float far_val)" 0
   "glOrtho (left, right, bottom, top, near_val, far_val);")
 
+(defcfun "void gacela_glPushMatrix (void)" 0
+  "glPushMatrix ();")
+
+(defcfun "void gacela_glPopMatrix (void)" 0
+  "glPopMatrix ();")
+
 (defcfun "void gacela_gluPerspective (double fovy, double aspect, double zNear, double zFar)" 0
   "gluPerspective (fovy, aspect, zNear, zFar);")
 
 (defcfun "int gacela_gluBuild2DMipmaps (int target, int internalFormat, int width, int height, int format, int type, int data)" 0
   "return gluBuild2DMipmaps (target, internalFormat, width, height, format, type, data);")
 
+(defcfun "void gacela_gluLookAt (double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ)" 0
+  "gluLookAt (eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);")
+
 (defentry glBegin (int) (void "gacela_glBegin"))
 (defentry glClear (int) (void "gacela_glClear"))
 (defentry glClearColor (float float float float) (void "gacela_glClearColor"))
 (defentry glClearDepth (double) (void "gacela_glClearDepth"))
 (defentry glColor3f (float float float) (void "gacela_glColor3f"))
+(defentry glColor4f (float float float float) (void "gacela_glColor4f"))
 (defentry glDepthFunc (int) (void "gacela_glDepthFunc"))
 (defentry glEnable (int) (void "gacela_glEnable"))
 (defentry glDisable (int) (void "gacela_glDisable"))
 (defentry glVertex3f (float float float) (void "gacela_glVertex3f"))
 (defentry glViewport (int int int int) (void "gacela_glViewport"))
 (defentry glGenTextures (int) (object "gacela_glGenTextures"))
+(defentry glDeleteTextures (int object) (void "gacela_glDeleteTextures"))
 (defentry glBindTexture (int int) (void "gacela_glBindTexture"))
 (defentry glTexImage2D (int int int int int int int int int) (void "gacela_glTexImage2D"))
 (defentry glTexParameteri (int int int) (void "gacela_glTexParameteri"))
 (defentry glNormal3f (float float float) (void "gacela_glNormal3f"))
 (defentry glBlendFunc (int int) (void "gacela_glBlendFunc"))
 (defentry glOrtho (float float float float float float) (void "gacela_glOrtho"))
+(defentry glPushMatrix () (void "gacela_glPushMatrix"))
+(defentry glPopMatrix () (void "gacela_glPopMatrix"))
 
 (defentry gluPerspective (double double double double) (void "gacela_gluPerspective"))
 (defentry gluBuild2DMipmaps (int int int int int int int) (int "gacela_gluBuild2DMipmaps"))
+(defentry gluLookAt (double double double double double double double double double) (void "gacela_gluLookAt"))