4 Simple DirectMedia Layer
5 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
7 Pascal-Header-Conversion
8 Copyright (C) 2012/13 Tim Blume aka End/EV1313
10 SDL.pas is based on the files:
48 cause there's a much better OpenGL-Header avaible at delphigl.com:
52 Parts of the SDL.pas are from the SDL-1.2-Headerconversion from the JEDI-Team,
53 written by Domenique Louis and others.
55 I've changed the names of the dll for 32 & 64-Bit, so theres no conflict
56 between 32 & 64 bit Libraries.
58 This software is provided 'as-is', without any express or implied
59 warranty. In no case will the authors be held liable for any damages
60 arising from the use of this software.
62 Permission is granted to anyone to use this software for any purpose,
63 including commercial applications, and to alter it and redistribute it
64 freely, subject to the following restrictions:
66 1. The origin of this software must not be misrepresented; you must not
67 claim that you wrote the original software. If you use this software
68 in a product, an acknowledgment in the product documentation would be
69 appreciated but is not required.
70 2. Altered source versions must be plainly marked as such, and must not be
71 misrepresented as being the original software.
72 3. This notice may not be removed or altered from any source distribution.
76 - DelphiGL.com - Community
77 - Domenique Louis and everyone else from the JEDI-Team
78 - Sam Latinga and everyone else from the SDL-Team
84 v.1.73-stable; 08.11.2013: added sdl_hints.h and some keystate helpers
86 v.1.72-stable; 23.09.2013: fixed bug with procedures without parameters
87 (they must have brakets)
88 v.1.70-stable; 17.09.2013: added "sdl_messagebox.h" and "sdl_haptic.h"
89 v.1.63-stable; 16.09.2013: added libs sdl2_image and sdl2_ttf and added sdl_audio.h
90 v.1.62-stable; 03.09.2013: fixed.
91 v.1.61-stable; 02.09.2013: now it should REALLY work with Mac...
92 v.1.60-stable; 01.09.2013: now it should work with Delphi XE4 for Windows and
93 MacOS and of course Lazarus. thx to kotai :D
94 v.1.55-Alpha; 24.08.2013: fixed bug with SDL_GetEventState thx to d.l.i.w.
95 v.1.54-Alpha; 24.08.2013: added sdl_loadso.h
96 v.1.53-Alpha; 24.08.2013: renamed *really* and fixed linux comp.
97 v.1.52-Alpha; 24.08.2013: renamed sdl.pas to sdl2.pas
98 v.1.51-Alpha; 24.08.2013: added sdl_platform.h
99 v.1.50-Alpha; 24.08.2013: the header is now modular. thx for the hint from d.l.i.w.
100 v.1.40-Alpha; 13.08.2013: Added MacOS compatibility (thx to stoney-fd)
101 v.1.34-Alpha; 05.08.2013: Added missing functions from sdl_thread.h
102 v.1.33-Alpha; 31.07.2013: Added missing units for Linux. thx to Cybermonkey
103 v.1.32-Alpha; 31.07.2013: Fixed three bugs, thx to grieferatwork
104 v.1.31-Alpha; 30.07.2013: Added "sdl_power.h"
105 v.1.30-Alpha; 26.07.2013: Added "sdl_thread.h" and "sdl_mutex.h"
106 v.1.25-Alpha; 29.07.2013: Added Makros for SDL_RWops
107 v.1.24-Alpha; 28.07.2013: Fixed bug with RWops and size_t
108 v.1.23-Alpha; 27.07.2013: Fixed two bugs, thx to GrieferAtWork
109 v.1.22-Alpha; 24.07.2013: Added "sdl_shape.h" and TSDL_Window
110 (and ordered the translated header list ^^)
111 v.1.21-Alpha; 23.07.2013: Added TSDL_Error
112 v.1.20-Alpha; 19.07.2013: Added "sdl_timer.h"
113 v.1.10-Alpha; 09.07.2013: Added "sdl_render.h"
114 v.1.00-Alpha; 05.07.2013: Initial Alpha-Release.
137 SDL_LibName = 'SDL2.dll';
142 SDL_LibName = 'libSDL2.dylib';
145 SDL_LibName = 'libSDL2.so';
147 SDL_LibName = 'libSDL2.so.0';
153 SDL_LibName = 'SDL2';
171 {$I sdlblendmode.inc}
176 {$I sdlmessagebox.inc}
190 //from "sdl_version.h"
191 procedure SDL_VERSION(x: PSDL_Version);
193 x.major := SDL_MAJOR_VERSION;
194 x.minor := SDL_MINOR_VERSION;
195 x.patch := SDL_PATCHLEVEL;
198 function SDL_VERSIONNUM(X,Y,Z: UInt32): Cardinal;
200 Result := X*1000 + Y*100 + Z;
203 function SDL_COMPILEDVERSION: Cardinal;
205 Result := SDL_VERSIONNUM(SDL_MAJOR_VERSION,
210 function SDL_VERSION_ATLEAST(X,Y,Z: Cardinal): Boolean;
212 Result := SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X,Y,Z);
216 //from "sdl_thread.h"
218 function SDL_CreateThread(fn: TSDL_ThreadFunction; name: PAnsiChar; data: Pointer): PSDL_Thread; overload;
220 Result := SDL_CreateThread(fn,name,data,nil,nil);
226 function SDL_RectEmpty(X: TSDL_Rect): Boolean;
228 Result := (X.w <= 0) or (X.h <= 0);
231 function SDL_RectEquals(A: TSDL_Rect; B: TSDL_Rect): Boolean;
233 Result := (A.x = B.x) and (A.y = B.y) and (A.w = B.w) and (A.h = B.h);
238 function SDL_RWsize(ctx: PSDL_RWops): SInt64;
240 Result := ctx^.size(ctx);
243 function SDL_RWseek(ctx: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64;
245 Result := ctx^.seek(ctx,offset,whence);
248 function SDL_RWtell(ctx: PSDL_RWops): SInt64;
250 Result := ctx^.seek(ctx, 0, RW_SEEK_CUR);
253 function SDL_RWread(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
255 Result := ctx^.read(ctx, ptr, size, n);
258 function SDL_RWwrite(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
260 Result := ctx^.write(ctx, ptr, size, n);
263 function SDL_RWclose(ctx: PSDL_RWops): SInt32;
265 Result := ctx^.close(ctx);
270 function SDL_LoadWAV(_file: PAnsiChar; spec: PSDL_AudioSpec; audio_buf: PPUInt8; audio_len: PUInt32): PSDL_AudioSpec;
272 Result := SDL_LoadWAV_RW(SDL_RWFromFile(_file, 'rb'), 1, spec, audio_buf, audio_len);
275 function SDL_AUDIO_BITSIZE(x: Cardinal): Cardinal;
277 Result := x and SDL_AUDIO_MASK_BITSIZE;
280 function SDL_AUDIO_ISFLOAT(x: Cardinal): Cardinal;
282 Result := x and SDL_AUDIO_MASK_DATATYPE;
285 function SDL_AUDIO_ISBIGENDIAN(x: Cardinal): Cardinal;
287 Result := x and SDL_AUDIO_MASK_ENDIAN;
290 function SDL_AUDIO_ISSIGNED(x: Cardinal): Cardinal;
292 Result := x and SDL_AUDIO_MASK_SIGNED;
295 function SDL_AUDIO_ISINT(x: Cardinal): Cardinal;
297 Result := not SDL_AUDIO_ISFLOAT(x);
300 function SDL_AUDIO_ISLITTLEENDIAN(x: Cardinal): Cardinal;
302 Result := not SDL_AUDIO_ISLITTLEENDIAN(x);
305 function SDL_AUDIO_ISUNSIGNED(x: Cardinal): Cardinal;
307 Result := not SDL_AUDIO_ISSIGNED(x);
310 //from "sdl_pixels.h"
312 function SDL_PIXELFLAG(X: Cardinal): Boolean;
314 Result := (X shr 28) = $0F;
317 function SDL_PIXELTYPE(X: Cardinal): Boolean;
319 Result := (X shr 24) = $0F;
322 function SDL_PIXELORDER(X: Cardinal): Boolean;
324 Result := (X shr 20) = $0F;
327 function SDL_PIXELLAYOUT(X: Cardinal): Boolean;
329 Result := (X shr 16) = $0F;
332 function SDL_BITSPERPIXEL(X: Cardinal): Boolean;
334 Result := (X shr 8) = $FF;
337 function SDL_IsPixelFormat_FOURCC(format: Variant): Boolean;
339 {* The flag is set to 1 because 0x1? is not in the printable ASCII range *}
340 Result := format and SDL_PIXELFLAG(format) <> 1;
343 //from "sdl_surface.h"
344 function SDL_LoadBMP(_file: PAnsiChar): PSDL_Surface;
346 Result := SDL_LoadBMP_RW(SDL_RWFromFile(_file, 'rb'), 1);
350 function SDL_WindowPos_IsUndefined(X: Variant): Variant;
352 Result := (X and $FFFF0000) = SDL_WINDOWPOS_UNDEFINED_MASK;
355 function SDL_WindowPos_IsCentered(X: Variant): Variant;
357 Result := (X and $FFFF0000) = SDL_WINDOWPOS_CENTERED_MASK;
360 //from "sdl_events.h"
362 function SDL_GetEventState(type_: UInt32): UInt8;
364 Result := SDL_EventState(type_, SDL_QUERY);