Skip to content

Commit b7faca6

Browse files
Add SDL3.pas
1 parent 0b28d7b commit b7faca6

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

units/sdl3.pas

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
unit SDL3;
2+
3+
{
4+
SDL3-for-Pascal
5+
=================
6+
Pascal units for SDL3 - Simple Direct MediaLayer, Version 3
7+
8+
(to be extended - todo)
9+
10+
}
11+
12+
{$I sdl.inc}
13+
14+
interface
15+
16+
{$IFDEF WINDOWS}
17+
uses
18+
{$IFDEF FPC}
19+
ctypes,
20+
{$ENDIF}
21+
Windows;
22+
{$ENDIF}
23+
24+
{$IF DEFINED(UNIX) AND NOT DEFINED(ANDROID)}
25+
uses
26+
{$IFDEF FPC}
27+
ctypes,
28+
UnixType,
29+
{$ENDIF}
30+
{$IFDEF DARWIN}
31+
CocoaAll;
32+
{$ELSE}
33+
X,
34+
XLib;
35+
{$ENDIF}
36+
{$ENDIF}
37+
38+
{$IF DEFINED(UNIX) AND DEFINED(ANDROID) AND DEFINED(FPC)}
39+
uses
40+
ctypes,
41+
UnixType;
42+
{$ENDIF}
43+
44+
const
45+
46+
{$IFDEF WINDOWS}
47+
SDL_LibName = 'SDL3.dll';
48+
{$ENDIF}
49+
50+
{$IFDEF UNIX}
51+
{$IFDEF DARWIN}
52+
SDL_LibName = 'libSDL3.dylib';
53+
{$IFDEF FPC}
54+
{$LINKLIB libSDL2}
55+
{$ENDIF}
56+
{$ELSE}
57+
{$IFDEF FPC}
58+
SDL_LibName = 'libSDL3.so';
59+
{$ELSE}
60+
SDL_LibName = 'libSDL3.so.0';
61+
{$ENDIF}
62+
{$ENDIF}
63+
{$ENDIF}
64+
65+
{$IFDEF MACOS}
66+
SDL_LibName = 'SDL3';
67+
{$IFDEF FPC}
68+
{$linklib libSDL3}
69+
{$ENDIF}
70+
{$ENDIF}
71+
72+
{ The include file translates
73+
corresponding C header file.
74+
Inc file was updated against
75+
SDL_init.inc --> SDL_init.h this version of the header file: }
76+
{$I SDL_init.inc} // 3.1.6-prev
77+
{$I SDL_log.inc} // 3.1.6-prev
78+
{$I SDL_version.inc} // 3.1.6-prev
79+
{$I SDL_revision.inc} // 3.1.6-prev
80+
81+
implementation
82+
83+
{ Macros from SDL_version.h }
84+
function SDL_VERSIONNUM(major, minor, patch: Integer): Integer;
85+
begin
86+
Result:=(major*1000000)+(minor*1000)+patch;
87+
end;
88+
89+
function SDL_VERSIONNUM_MAJOR(version: Integer): Integer;
90+
begin
91+
Result:=version div 1000000;
92+
end;
93+
94+
function SDL_VERSIONNUM_MINOR(version: Integer): Integer;
95+
begin
96+
Result:=(version div 1000) mod 1000;
97+
end;
98+
99+
function SDL_VERSIONNUM_MICRO(version: Integer): Integer;
100+
begin
101+
Result:=version mod 1000;
102+
end;
103+
104+
function SDL_VERSION: Integer;
105+
begin
106+
Result:=SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
107+
end;
108+
109+
function SDL_VERSION_ATLEAST(X, Y, Z: Integer): Boolean;
110+
begin
111+
if (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z)) then
112+
Result:=True
113+
else
114+
Result:=False;
115+
end;
116+
117+
end.
118+

0 commit comments

Comments
 (0)