DEADSOFTWARE

added opengl and sdl2 wrappers to allegro (WIP)
[d2df-sdl.git] / src / wrappers / sdl2 / sdlpixels.inc
1 //from "sdl_pixels.h"
3 {**
4 * Transparency definitions
5 *
6 * These define alpha as the opacity of a surface.
7 *}
9 const
10 SDL_ALPHA_OPAQUE = 255;
11 SDL_ALPHA_TRANSPARENT = 0;
13 {** Pixel type. *}
14 SDL_PIXELTYPE_UNKNOWN = 0;
15 SDL_PIXELTYPE_INDEX1 = 1;
16 SDL_PIXELTYPE_INDEX4 = 2;
17 SDL_PIXELTYPE_INDEX8 = 3;
18 SDL_PIXELTYPE_PACKED8 = 4;
19 SDL_PIXELTYPE_PACKED16 = 5;
20 SDL_PIXELTYPE_PACKED32 = 6;
21 SDL_PIXELTYPE_ARRAYU8 = 7;
22 SDL_PIXELTYPE_ARRAYU16 = 8;
23 SDL_PIXELTYPE_ARRAYU32 = 9;
24 SDL_PIXELTYPE_ARRAYF16 = 10;
25 SDL_PIXELTYPE_ARRAYF32 = 11;
27 {** Bitmap pixel order, high bit -> low bit. *}
28 SDL_BITMAPORDER_NONE = 0;
29 SDL_BITMAPORDER_4321 = 1;
30 SDL_BITMAPORDER_1234 = 2;
32 {** Packed component order, high bit -> low bit. *}
34 SDL_PACKEDORDER_NONE = 0;
35 SDL_PACKEDORDER_XRGB = 1;
36 SDL_PACKEDORDER_RGBX = 2;
37 SDL_PACKEDORDER_ARGB = 3;
38 SDL_PACKEDORDER_RGBA = 4;
39 SDL_PACKEDORDER_XBGR = 5;
40 SDL_PACKEDORDER_BGRX = 6;
41 SDL_PACKEDORDER_ABGR = 7;
42 SDL_PACKEDORDER_BGRA = 8;
44 {** Array component order, low byte -> high byte. *}
45 SDL_ARRAYORDER_NONE = 0;
46 SDL_ARRAYORDER_RGB = 1;
47 SDL_ARRAYORDER_RGBA = 2;
48 SDL_ARRAYORDER_ARGB = 3;
49 SDL_ARRAYORDER_BGR = 4;
50 SDL_ARRAYORDER_BGRA = 5;
51 SDL_ARRAYORDER_ABGR = 6;
53 {** Packed component layout. *}
54 SDL_PACKEDLAYOUT_NONE = 0;
55 SDL_PACKEDLAYOUT_332 = 1;
56 SDL_PACKEDLAYOUT_4444 = 2;
57 SDL_PACKEDLAYOUT_1555 = 3;
58 SDL_PACKEDLAYOUT_5551 = 4;
59 SDL_PACKEDLAYOUT_565 = 5;
60 SDL_PACKEDLAYOUT_8888 = 6;
61 SDL_PACKEDLAYOUT_2101010 = 7;
62 SDL_PACKEDLAYOUT_1010102 = 8;
64 {
65 //todo!!
66 function SDL_DEFINE_PIXELFORMAT(type, order, layour, bit, bytes: UInt32): Result;
68 function SDL_DEFINE_PIXELFOURCC(A,B,C,D: Variant): Variant;
70 #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
71 ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
72 ((bits) << 8) | ((bytes) << 0))
73 }
75 function SDL_PIXELFLAG(X: Cardinal): Cardinal;
76 function SDL_PIXELTYPE(X: Cardinal): Cardinal;
77 function SDL_PIXELORDER(X: Cardinal): Cardinal;
78 function SDL_PIXELLAYOUT(X: Cardinal): Cardinal;
79 function SDL_BITSPERPIXEL(X: Cardinal): Cardinal;
80 {
81 #define SDL_BYTESPERPIXEL(X) \
82 (SDL_ISPIXELFORMAT_FOURCC(X) ? \
83 ((((X) == SDL_PIXELFORMAT_YUY2) || \
84 ((X) == SDL_PIXELFORMAT_UYVY) || \
85 ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
87 #define SDL_ISPIXELFORMAT_INDEXED(format) \
88 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
89 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
90 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
91 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
93 #define SDL_ISPIXELFORMAT_ALPHA(format) \
94 (!SDL_ISPIXELFORMAT_FOURCC(format) && \
95 ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
96 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
97 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
98 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
100 function SDL_IsPixelFormat_FOURCC(format: Variant);
102 {* Note: If you modify this list, update SDL_GetPixelFormatName() *}
104 const
105 SDL_PIXELFORMAT_UNKNOWN = 0;
106 SDL_PIXELFORMAT_INDEX1LSB = (1 shl 28) or
107 (SDL_PIXELTYPE_INDEX1 shl 24) or
108 (SDL_BITMAPORDER_4321 shl 20) or
109 (0 shl 16) or
110 (1 shl 8) or
111 (0 shl 0);
113 SDL_PIXELFORMAT_INDEX1MSB = (1 shl 28) or
114 (SDL_PIXELTYPE_INDEX1 shl 24) or
115 (SDL_BITMAPORDER_1234 shl 20) or
116 (0 shl 16) or
117 (1 shl 8) or
118 (0 shl 0);
120 SDL_PIXELFORMAT_INDEX4LSB = (1 shl 28) or
121 (SDL_PIXELTYPE_INDEX4 shl 24) or
122 (SDL_BITMAPORDER_4321 shl 20) or
123 (0 shl 16) or
124 (4 shl 8) or
125 (0 shl 0);
127 SDL_PIXELFORMAT_INDEX4MSB = (1 shl 28) or
128 (SDL_PIXELTYPE_INDEX4 shl 24) or
129 (SDL_BITMAPORDER_1234 shl 20) or
130 (0 shl 16) or
131 (4 shl 8) or
132 (0 shl 0);
134 SDL_PIXELFORMAT_INDEX8 = (1 shl 28) or
135 (SDL_PIXELTYPE_PACKED8 shl 24) or
136 (0 shl 20) or
137 (0 shl 16) or
138 (8 shl 8) or
139 (1 shl 0);
141 SDL_PIXELFORMAT_RGB332 = (1 shl 28) or
142 (SDL_PIXELTYPE_PACKED8 shl 24) or
143 (SDL_PACKEDORDER_XRGB shl 20) or
144 (SDL_PACKEDLAYOUT_332 shl 16) or
145 (8 shl 8) or
146 (1 shl 0);
148 SDL_PIXELFORMAT_RGB444 = (1 shl 28) or
149 (SDL_PIXELTYPE_PACKED16 shl 24) or
150 (SDL_PACKEDORDER_XRGB shl 20) or
151 (SDL_PACKEDLAYOUT_4444 shl 16) or
152 (12 shl 8) or
153 (2 shl 0);
155 SDL_PIXELFORMAT_RGB555 = (1 shl 28) or
156 (SDL_PIXELTYPE_PACKED16 shl 24) or
157 (SDL_PACKEDORDER_XRGB shl 20) or
158 (SDL_PACKEDLAYOUT_1555 shl 16) or
159 (15 shl 8) or
160 (2 shl 0);
162 SDL_PIXELFORMAT_BGR555 = (1 shl 28) or
163 (SDL_PIXELTYPE_PACKED16 shl 24) or
164 (SDL_PACKEDORDER_XBGR shl 20) or
165 (SDL_PACKEDLAYOUT_1555 shl 16) or
166 (15 shl 8) or
167 (2 shl 0);
169 SDL_PIXELFORMAT_ARGB4444 = (1 shl 28) or
170 (SDL_PIXELTYPE_PACKED16 shl 24) or
171 (SDL_PACKEDORDER_ARGB shl 20) or
172 (SDL_PACKEDLAYOUT_4444 shl 16) or
173 (16 shl 8) or
174 (2 shl 0);
176 SDL_PIXELFORMAT_RGBA4444 = (1 shl 28) or
177 (SDL_PIXELTYPE_PACKED16 shl 24) or
178 (SDL_PACKEDORDER_RGBA shl 20) or
179 (SDL_PACKEDLAYOUT_4444 shl 16) or
180 (16 shl 8) or
181 (2 shl 0);
183 SDL_PIXELFORMAT_ABGR4444 = (1 shl 28) or
184 (SDL_PIXELTYPE_PACKED16 shl 24) or
185 (SDL_PACKEDORDER_ABGR shl 20) or
186 (SDL_PACKEDLAYOUT_4444 shl 16) or
187 (16 shl 8) or
188 (2 shl 0);
190 SDL_PIXELFORMAT_BGRA4444 = (1 shl 28) or
191 (SDL_PIXELTYPE_PACKED16 shl 24) or
192 (SDL_PACKEDORDER_BGRA shl 20) or
193 (SDL_PACKEDLAYOUT_4444 shl 16) or
194 (16 shl 8) or
195 (2 shl 0);
197 SDL_PIXELFORMAT_ARGB1555 = (1 shl 28) or
198 (SDL_PIXELTYPE_PACKED16 shl 24) or
199 (SDL_PACKEDORDER_ARGB shl 20) or
200 (SDL_PACKEDLAYOUT_1555 shl 16) or
201 (16 shl 8) or
202 (2 shl 0);
204 SDL_PIXELFORMAT_RGBA5551 = (1 shl 28) or
205 (SDL_PIXELTYPE_PACKED16 shl 24) or
206 (SDL_PACKEDORDER_RGBA shl 20) or
207 (SDL_PACKEDLAYOUT_5551 shl 16) or
208 (16 shl 8) or
209 (2 shl 0);
211 SDL_PIXELFORMAT_ABGR1555 = (1 shl 28) or
212 (SDL_PIXELTYPE_PACKED16 shl 24) or
213 (SDL_PACKEDORDER_ABGR shl 20) or
214 (SDL_PACKEDLAYOUT_1555 shl 16) or
215 (16 shl 8) or
216 (2 shl 0);
218 SDL_PIXELFORMAT_BGRA5551 = (1 shl 28) or
219 (SDL_PIXELTYPE_PACKED16 shl 24) or
220 (SDL_PACKEDORDER_BGRA shl 20) or
221 (SDL_PACKEDLAYOUT_5551 shl 16) or
222 (16 shl 8) or
223 (2 shl 0);
225 SDL_PIXELFORMAT_RGB565 = (1 shl 28) or
226 (SDL_PIXELTYPE_PACKED16 shl 24) or
227 (SDL_PACKEDORDER_XRGB shl 20) or
228 (SDL_PACKEDLAYOUT_565 shl 16) or
229 (16 shl 8) or
230 (2 shl 0);
232 SDL_PIXELFORMAT_BGR565 = (1 shl 28) or
233 (SDL_PIXELTYPE_PACKED16 shl 24) or
234 (SDL_PACKEDORDER_XBGR shl 20) or
235 (SDL_PACKEDLAYOUT_1555 shl 16) or
236 (16 shl 8) or
237 (2 shl 0);
239 SDL_PIXELFORMAT_RGB24 = (1 shl 28) or
240 (SDL_PIXELTYPE_ARRAYU8 shl 24) or
241 (SDL_ARRAYORDER_RGB shl 20) or
242 (0 shl 16) or
243 (24 shl 8) or
244 (3 shl 0);
246 SDL_PIXELFORMAT_BGR24 = (1 shl 28) or
247 (SDL_PIXELTYPE_ARRAYU8 shl 24) or
248 (SDL_ARRAYORDER_BGR shl 20) or
249 (0 shl 16) or
250 (24 shl 8) or
251 (3 shl 0);
253 SDL_PIXELFORMAT_RGB888 = (1 shl 28) or
254 (SDL_PIXELTYPE_PACKED32 shl 24) or
255 (SDL_PACKEDORDER_XRGB shl 20) or
256 (SDL_PACKEDLAYOUT_8888 shl 16) or
257 (24 shl 8) or
258 (4 shl 0);
260 SDL_PIXELFORMAT_RGBX8888 = (1 shl 28) or
261 (SDL_PIXELTYPE_PACKED32 shl 24) or
262 (SDL_PACKEDORDER_RGBX shl 20) or
263 (SDL_PACKEDLAYOUT_8888 shl 16) or
264 (24 shl 8) or
265 (4 shl 0);
267 SDL_PIXELFORMAT_BGR888 = (1 shl 28) or
268 (SDL_PIXELTYPE_PACKED32 shl 24) or
269 (SDL_PACKEDORDER_XBGR shl 20) or
270 (SDL_PACKEDLAYOUT_8888 shl 16) or
271 (24 shl 8) or
272 (4 shl 0);
274 SDL_PIXELFORMAT_BGRX8888 = (1 shl 28) or
275 (SDL_PIXELTYPE_PACKED32 shl 24) or
276 (SDL_PACKEDORDER_BGRX shl 20) or
277 (SDL_PACKEDLAYOUT_8888 shl 16) or
278 (24 shl 8) or
279 (4 shl 0);
281 SDL_PIXELFORMAT_ARGB8888 = (1 shl 28) or
282 (SDL_PIXELTYPE_PACKED32 shl 24) or
283 (SDL_PACKEDORDER_ARGB shl 20) or
284 (SDL_PACKEDLAYOUT_8888 shl 16) or
285 (32 shl 8) or
286 (4 shl 0);
288 SDL_PIXELFORMAT_RGBA8888 = (1 shl 28) or
289 (SDL_PIXELTYPE_PACKED32 shl 24) or
290 (SDL_PACKEDORDER_RGBA shl 20) or
291 (SDL_PACKEDLAYOUT_8888 shl 16) or
292 (32 shl 8) or
293 (4 shl 0);
295 SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or
296 (SDL_PIXELTYPE_PACKED32 shl 24) or
297 (SDL_PACKEDORDER_ABGR shl 20) or
298 (SDL_PACKEDLAYOUT_8888 shl 16) or
299 (32 shl 8) or
300 (4 shl 0);
302 SDL_PIXELFORMAT_BGRA8888 = (1 shl 28) or
303 (SDL_PIXELTYPE_PACKED32 shl 24) or
304 (SDL_PACKEDORDER_RGBX shl 20) or
305 (SDL_PACKEDLAYOUT_8888 shl 16) or
306 (32 shl 8) or
307 (4 shl 0);
309 SDL_PIXELFORMAT_ARGB2101010 = (1 shl 28) or
310 (SDL_PIXELTYPE_PACKED32 shl 24) or
311 (SDL_PACKEDORDER_ARGB shl 20) or
312 (SDL_PACKEDLAYOUT_2101010 shl 16)or
313 (32 shl 8) or
314 (4 shl 0);
316 {**< Planar mode: Y + V + U (3 planes) *}
317 SDL_PIXELFORMAT_YV12 = (Integer('Y') ) or
318 (Integer('V') shl 8) or
319 (Integer('1') shl 16) or
320 (Integer('2') shl 24);
321 {**< Planar mode: Y + U + V (3 planes) *}
322 SDL_PIXELFORMAT_IYUV = (Integer('I') ) or
323 (Integer('Y') shl 8) or
324 (Integer('U') shl 16) or
325 (Integer('V') shl 24);
326 {**< Packed mode: Y0+U0+Y1+V0 (1 plane) *}
327 SDL_PIXELFORMAT_YUY2 = (Integer('Y') ) or
328 (Integer('U') shl 8) or
329 (Integer('Y') shl 16) or
330 (Integer('2') shl 24);
331 {**< Packed mode: U0+Y0+V0+Y1 (1 plane) *}
332 SDL_PIXELFORMAT_UYVY = (Integer('U') ) or
333 (Integer('Y') shl 8) or
334 (Integer('V') shl 16) or
335 (Integer('Y') shl 24);
336 {**< Packed mode: Y0+V0+Y1+U0 (1 plane) *}
337 SDL_PIXELFORMAT_YVYU = (Integer('Y') ) or
338 (Integer('V') shl 8) or
339 (Integer('Y') shl 16) or
340 (Integer('U') shl 24);
342 type
343 PSDL_Color = ^TSDL_Color;
344 TSDL_Color = record
345 r: UInt8;
346 g: UInt8;
347 b: UInt8;
348 a: UInt8;
349 end;
351 TSDL_Colour = TSDL_Color;
352 PSDL_Colour = ^TSDL_Colour;
354 PSDL_Palette = ^TSDL_Palette;
355 TSDL_Palette = record
356 ncolors: SInt32;
357 colors: PSDL_Color;
358 version: UInt32;
359 refcount: SInt32;
360 end;
362 {**
363 * Everything in the pixel format structure is read-only.
364 *}
366 PSDL_PixelFormat = ^TSDL_PixelFormat;
367 TSDL_PixelFormat = record
368 format: UInt32;
369 palette: PSDL_Palette;
370 BitsPerPixel: UInt8;
371 BytesPerPixel: UInt8;
372 padding: array[0..1] of UInt8;
373 Rmask: UInt32;
374 Gmask: UInt32;
375 Bmask: UInt32;
376 Amask: UInt32;
377 Rloss: UInt8;
378 Gloss: UInt8;
379 Bloss: UInt8;
380 Aloss: UInt8;
381 Rshift: UInt8;
382 Gshift: UInt8;
383 Bshift: UInt8;
384 Ashift: UInt8;
385 refcount: SInt32;
386 next: PSDL_PixelFormat;
387 end;