Merge branch 'master' of ssh://repo.or.cz/srv/git/cl-devil
[cl-devil.git] / il.lisp
blobc31d3f7bdca2f77d570493c1d3c5a57e96b1389b
1 ;;;; cl-devil -- DevIL binding for CL. See README for licensing information.
3 (in-package :il)
5 (define-foreign-library il
6 (:unix (:or "libIL" "libIL.so.1"))
7 (t (:default "libIL")))
8 (use-foreign-library il)
10 (defctype handle :pointer)
11 (defcenum image-type
12 (:unknown #x0000)
13 (:bmp #x0420)
14 (:cut #x0421)
15 (:doom #x0422)
16 (:doom-flat #x0423)
17 (:ico #x0424)
18 (:jpg #x0425)
19 (:jfif #x0425)
20 (:lbm #x0426)
21 (:pcd #x0427)
22 (:pcx #x0428)
23 (:pic #x0429)
24 (:png #x042A)
25 (:pnm #x042B)
26 (:sgi #x042C)
27 (:tga #x042D)
28 (:tif #x042E)
29 (:chead #x042F)
30 (:raw #x0430)
31 (:mdl #x0431)
32 (:wal #x0432)
33 (:lif #x0434)
34 (:mng #x0435)
35 (:jng #x0435)
36 (:gif #x0436)
37 (:dds #x0437)
38 (:dcx #x0438)
39 (:psd #x0439)
40 (:exif #x043A)
41 (:psp #x043B)
42 (:pix #x043C)
43 (:pxr #x043D)
44 (:xpm #x043E)
45 (:hdr #x043F)
46 (:jasc-pal #x0475))
48 (defcenum data-format
49 (:colour-index #x1900)
50 (:color-index #x1900)
51 (:rgb #x1907)
52 (:rgba #x1908)
53 (:bgr #x80E0)
54 (:bgra #x80E1)
55 (:luminance #x1909)
56 (:luminance-alpha #x190A))
58 (defcenum data-type
59 (:byte #x1400)
60 (:unsigned-byte #x1401)
61 (:short #x1402)
62 (:unsigned-short #x1403)
63 (:int #x1404)
64 (:unsigned-int #x1405)
65 (:float #x1406)
66 (:double #x140A))
68 (defcenum error
69 (:no-error #x0000)
70 (:invalid-enum #x0501)
71 (:out-of-memory #x0502)
72 (:format-not-supported #x0503)
73 (:internal-error #x0504)
74 (:invalid-value #x0505)
75 (:illegal-operation #x0506)
76 (:illegal-file-value #x0507)
77 (:invalid-file-header #x0508)
78 (:invalid-param #x0509)
79 (:could-not-open-file #x050A)
80 (:invalid-extension #x050B)
81 (:file-already-exists #x050C)
82 (:out-format-same #x050D)
83 (:stack-overflow #x050E)
84 (:stack-underflow #x050F)
85 (:invalid-conversion #x0510)
86 (:bad-dimensions #x0511)
87 (:file-read-error #x0512)
88 (:file-write-error #x0512)
89 (:lib-gif-error #x05E1)
90 (:lib-jpeg-error #x05E2)
91 (:lib-png-error #x05E3)
92 (:lib-tiff-error #x05E4)
93 (:lib-mng-error #x05E5)
94 (:unknown-error #x05FF))
96 (defcenum mode
97 (:file-overwrite #x0620)
98 (:file-mode #x0621)
99 (:conv-pal #x0630)
100 (:use-key-color #x0635)
101 (:png-alpha-index #x0724)
102 (:version-num #x0DE2)
103 (:image-width #x0DE4)
104 (:image-height #x0DE5)
105 (:image-depth #x0DE6)
106 (:image-size-of-data #x0DE7)
107 (:image-bpp #x0DE8)
108 (:image-bytes-per-pixel #x0DE8)
109 (:image-bits-per-pixel #x0DE9)
110 (:image-format #x0DEA)
111 (:image-type #x0DEB)
112 (:palette-type #x0DEC)
113 (:palette-size #x0DED)
114 (:palette-bpp #x0DEE)
115 (:palette-num-cols #x0DEF)
116 (:palette-base-type #x0DF0)
117 (:num-images #x0DF1)
118 (:num-mipmaps #x0DF2)
119 (:num-layers #x0DF3)
120 (:active-image #x0DF4)
121 (:active-mipmap #x0DF5)
122 (:active-layer #x0DF6)
123 (:cur-image #x0DF7)
124 (:image-duration #x0DF8)
125 (:image-planesize #x0DF9)
126 (:image-bpc #x0DFA)
127 (:image-offx #x0DFB)
128 (:image-offy #x0DFC)
129 (:image-cubeflags #x0DFD)
130 (:image-origin #x0DFE)
131 (:image-channels #x0DFF))
133 (define-foreign-type pathname-string-type ()
135 (:actual-type :string)
136 (:simple-parser pathname-string))
137 (eval-when (:compile-toplevel :load-toplevel)
138 (defmethod expand-to-foreign-dyn (value var body (type pathname-string-type))
139 `(with-foreign-string (,var (if (pathnamep ,value) (namestring ,value) ,value))
140 ,@body)))
142 (defcfun ("ilInit" init) :void)
143 (defcfun ("ilShutDown" shutdown) :void)
144 (defcfun ("ilGenImages" %gen-images) :void (num :int) (images :pointer))
145 (defcfun ("ilBindImage" bind-image) :void (image :int))
146 (defcfun ("ilDeleteImages" delete-images) :void (num :int) (images :pointer))
147 (defcfun ("ilLoadImage" load-image) :boolean (file-name pathname-string))
148 (defcfun ("ilLoad" load) :boolean (type image-type) (file-name pathname-string))
149 (defcfun ("ilLoadF" load-f) :boolean (type image-type) (file handle))
150 (defcfun ("ilLoadL" load-l) :boolean (type image-type) (lump :pointer) (size :uint))
151 (defcfun ("ilSaveImage" save-image) :boolean (file-name pathname-string))
152 (defcfun ("ilSave" save) :boolean (type image-type) (file-name pathname-string))
153 (defcfun ("ilSaveF" save-f) :boolean (type image-type) (file handle))
154 (defcfun ("ilSaveL" save-l) :boolean (type image-type) (lump :pointer) (size :uint))
155 (defcfun ("ilTexImage" tex-image) :boolean
156 (width :uint) (height :uint) (depth :uint) (bpp :uint8) (format data-format) (type data-type) (data :pointer))
157 (defcfun ("ilGetData" get-data) :pointer)
158 (defcfun ("ilCopyPixels" copy-pixels) :uint
159 (x-offset :uint) (y-offset :uint) (z-offset :uint) (width :uint) (height :uint) (depth :uint) (format data-format) (type data-type) (data :pointer))
160 (defcfun ("ilSetData" set-data) :pointer)
161 (defcfun ("ilSetPixels" set-pixels) :uint
162 (x-offset :uint) (y-offset :uint) (z-offset :uint) (width :uint) (height :uint) (depth :uint) (format data-format) (type data-type) (data :pointer))
163 (defcfun ("ilCopyImage" copy-image) :boolean (source :uint))
164 (defcfun ("ilOverlayImage" overlay-image) :boolean (source :uint) (x-coord :int) (y-coord :int) (z-coord :int))
165 (defcfun ("ilBlit" blit) :boolean (source :uint) (dest-x :int) (dest-y :int) (dest-z :int) (src-x :int) (src-y :int) (src-z :int) (width :uint) (height :uint) (depth :uint))
166 (defcfun ("ilGetError" get-error) error)
168 (defcfun ("ilKeyColour" key-color) :void (red :float) (green :float) (blue :float) (alpha :float))
169 (defcfun ("ilGetPalette" get-palette) :pointer)
171 (defcfun ("ilGetInteger" get-integer) :uint (mode mode))
172 (defcfun ("ilSetInteger" set-integer) :void (mode mode) (param :int))
173 (defcfun ("ilEnable" enable) :boolean (mode mode))
174 (defcfun ("ilDisable" disable) :boolean (mode mode))
175 (defcfun ("ilIsEnabled" enabled-p) :boolean (mode mode))
177 (defcfun ("ilConvertImage" convert-image) :boolean (format data-format) (type data-type))
178 (defcfun ("ilFlipImage" flip-image) :boolean)
180 (defcfun ("ilDetermineType" determine-type) image-type (pathname pathname-string))