]> git.jsancho.org Git - gacela.git/blob - gacela_GL.lisp
(no commit message)
[gacela.git] / gacela_GL.lisp
1 ;;; Gacela, a GNU Common Lisp extension for fast games development
2 ;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
3 ;;;
4 ;;; This program is free software: you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation, either version 3 of the License, or
7 ;;; (at your option) any later version.
8 ;;;
9 ;;; This program is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ;;; GNU General Public License for more details.
13 ;;;
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18 (in-package :gacela)
19
20 (clines "#include <GL/gl.h>")
21 (clines "#include <GL/glu.h>")
22
23 ;;; Data types
24 (defconstant GL_UNSIGNED_BYTE                 #x1401)
25
26 ;;; Primitives
27 (defconstant GL_POINTS                        #x0000)
28 (defconstant GL_LINES                         #x0001)
29 (defconstant GL_LINE_LOOP                     #x0002)
30 (defconstant GL_LINE_STRIP                    #x0003)
31 (defconstant GL_TRIANGLES                     #x0004)
32 (defconstant GL_TRIANGLE_STRIP                #x0005)
33 (defconstant GL_TRIANGLE_FAN                  #x0006)
34 (defconstant GL_QUADS                         #x0007)
35 (defconstant GL_QUAD_STRIP                    #x0008)
36 (defconstant GL_POLYGON                       #x0009)
37
38 ;;; Matrix Mode
39 (defconstant GL_MODELVIEW                     #x1700)
40 (defconstant GL_PROJECTION                    #x1701)
41
42 ;;; Depth buffer
43 (defconstant GL_LEQUAL                        #x0203)
44 (defconstant GL_DEPTH_TEST                    #x0B71)
45
46 ;;; Lighting
47 (defconstant GL_LIGHTING                      #x0B50)
48 (defconstant GL_LIGHT1                        #x4001)
49 (defconstant GL_AMBIENT                       #x1200)
50 (defconstant GL_DIFFUSE                       #x1201)
51 (defconstant GL_POSITION                      #x1203)
52 (defconstant GL_SMOOTH                        #x1D01)
53
54 ;;; Blending
55 (defconstant GL_BLEND                         #x0BE2)
56 (defconstant GL_ONE                           #x1)
57 (defconstant GL_SRC_ALPHA                     #x0302)
58
59 ;;; Fog
60 (defconstant GL_LINEAR                        #x2601)
61
62 ;;; Buffers, Pixel Drawing/Reading
63 (defconstant GL_RGB                           #x1907)
64
65 ;;; Hints
66 (defconstant GL_PERSPECTIVE_CORRECTION_HINT   #x0C50)
67 (defconstant GL_NICEST                        #x1102)
68
69 ;;; Texture mapping
70 (defconstant GL_TEXTURE_2D                    #x0DE1)
71 (defconstant GL_TEXTURE_MAG_FILTER            #x2800)
72 (defconstant GL_TEXTURE_MIN_FILTER            #x2801)
73 (defconstant GL_LINEAR_MIPMAP_NEAREST         #x2701)
74 (defconstant GL_NEAREST                       #x2600)
75
76 ;;; glPush/PopAttrib bits
77 (defconstant GL_DEPTH_BUFFER_BIT              #x00000100)
78 (defconstant GL_COLOR_BUFFER_BIT              #x00004000)
79
80 ;;; OpenGL 1.2
81 (defconstant GL_BGR                           #x80E0)
82
83 ;;; OpenGL Functions
84 (defcfun "void gacela_glBegin (int mode)" 0
85   "glBegin (mode);")
86
87 (defcfun "void gacela_glClear (int mask)" 0
88   "glClear (mask);")
89
90 (defcfun "void gacela_glClearColor (float red, float green, float blue, float alpha)" 0
91   "glClearColor (red, green, blue, alpha);")
92
93 (defcfun "void gacela_glClearDepth (double depth)" 0
94   "glClearDepth (depth);")
95
96 (defcfun "void gacela_glColor3f (float red, float green, float blue)" 0
97   "glColor3f (red, green, blue);")
98
99 (defcfun "void gacela_glDepthFunc (int func)" 0
100   "glDepthFunc (func);")
101
102 (defcfun "void gacela_glEnable (int cap)" 0
103   "glEnable (cap);")
104
105 (defcfun "void gacela_glDisable (int cap)" 0
106   "glDisable (cap);")
107
108 (defcfun "void gacela_glEnd (void)" 0
109   "glEnd ();")
110
111 (defcfun "void gacela_glHint (int target, int mode)" 0
112   "glHint (target, mode);")
113
114 (defcfun "void gacela_glLoadIdentity (void)" 0
115   "glLoadIdentity ();")
116
117 (defcfun "void gacela_glMatrixMode (int mode)" 0
118   "glMatrixMode (mode);")
119
120 (defcfun "void gacela_glRotatef (float angle, float x, float y, float z)" 0
121   "glRotatef (angle, x, y, z);")
122
123 (defcfun "void gacela_glShadeModel (int mode)" 0
124   "glShadeModel (mode);")
125
126 (defcfun "void gacela_glTranslatef (float x, float y, float z)" 0
127   "glTranslatef (x, y, z);")
128
129 (defcfun "void gacela_glVertex3f (float x, float y, float z)" 0
130   "glVertex3f (x, y, z);")
131
132 (defcfun "void gacela_glViewport (int x, int y, int width, int height)" 0
133   "glViewport (x, y, width, height);")
134
135 (defcfun "static object gacela_glGenTextures (int n)" 0
136   "object textures;"
137   "GLuint text[n];"
138   "int i, t;"
139   ('nil textures)
140   "glGenTextures (n, &text[0]);"
141   "for (i = n - 1; i >= 0; i--) {"
142   "t = text[i];"
143   ((cons (int t) textures) textures)
144   "}"
145   "return textures;")
146
147 (defcfun "void gacela_glBindTexture (int target, int texture)" 0
148   "glBindTexture (target, texture);")
149
150 (defcfun "void gacela_glTexImage2D (int target, int level, int internalFormat, int width, int height, int border, int format, int type, int pixels)" 0
151   "glTexImage2D (target, level, internalFormat, width, height, border, format, type, pixels);")
152
153 (defcfun "void gacela_glTexParameteri (int target, int pname, int param)" 0
154   "glTexParameteri (target, pname, param);")
155
156 (defcfun "void gacela_glTexCoord2f (float s, float t)" 0
157   "glTexCoord2f (s, t);")
158
159 (defcfun "void gacela_glLightfv (int light, int pname, float param1, float param2, float param3, float param4)" 0
160   "GLfloat params[4];"
161   "params[0] = param1;"
162   "params[1] = param2;"
163   "params[2] = param3;"
164   "params[3] = param4;"
165   "glLightfv (light, pname, params);")
166
167 (defcfun "void gacela_glNormal3f (float nx, float ny, float nz)" 0
168   "glNormal3f (nx, ny, nz);")
169
170 (defcfun "void gacela_glBlendFunc (int sfactor, int dfactor)" 0
171   "glBlendFunc (sfactor, dfactor);")
172
173 (defcfun "void gacela_gluPerspective (double fovy, double aspect, double zNear, double zFar)" 0
174   "gluPerspective (fovy, aspect, zNear, zFar);")
175
176 (defcfun "int gacela_gluBuild2DMipmaps (int target, int internalFormat, int width, int height, int format, int type, int data)" 0
177   "return gluBuild2DMipmaps (target, internalFormat, width, height, format, type, data);")
178
179 (defentry glBegin (int) (void "gacela_glBegin"))
180 (defentry glClear (int) (void "gacela_glClear"))
181 (defentry glClearColor (float float float float) (void "gacela_glClearColor"))
182 (defentry glClearDepth (double) (void "gacela_glClearDepth"))
183 (defentry glColor3f (float float float) (void "gacela_glColor3f"))
184 (defentry glDepthFunc (int) (void "gacela_glDepthFunc"))
185 (defentry glEnable (int) (void "gacela_glEnable"))
186 (defentry glDisable (int) (void "gacela_glDisable"))
187 (defentry glEnd () (void "gacela_glEnd"))
188 (defentry glHint (int int) (void "gacela_glHint"))
189 (defentry glLoadIdentity () (void "gacela_glLoadIdentity"))
190 (defentry glMatrixMode (int) (void "gacela_glMatrixMode"))
191 (defentry glRotatef (float float float float) (void "gacela_glRotatef"))
192 (defentry glShadeModel (int) (void "gacela_glShadeModel"))
193 (defentry glTranslatef (float float float) (void "gacela_glTranslatef"))
194 (defentry glVertex3f (float float float) (void "gacela_glVertex3f"))
195 (defentry glViewport (int int int int) (void "gacela_glViewport"))
196 (defentry glGenTextures (int) (object "gacela_glGenTextures"))
197 (defentry glBindTexture (int int) (void "gacela_glBindTexture"))
198 (defentry glTexImage2D (int int int int int int int int int) (void "gacela_glTexImage2D"))
199 (defentry glTexParameteri (int int int) (void "gacela_glTexParameteri"))
200 (defentry glTexCoord2f (float float) (void "gacela_glTexCoord2f"))
201 (defentry glLightfv (int int float float float float) (void "gacela_glLightfv"))
202 (defentry glNormal3f (float float float) (void "gacela_glNormal3f"))
203 (defentry glBlendFunc (int int) (void "gacela_glBlendFunc"))
204
205 (defentry gluPerspective (double double double double) (void "gacela_gluPerspective"))
206 (defentry gluBuild2DMipmaps (int int int int int int int) (int "gacela_gluBuild2DMipmaps"))