Skip to content

Commit 88254b9

Browse files
Add new include files and macro functions
1 parent 10917a0 commit 88254b9

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

units/SDL3.pas

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ interface
6969
{$ENDIF}
7070
{$ENDIF}
7171

72+
{$I ctypes.inc} // C data types
73+
7274
{ The include file translates
7375
corresponding C header file.
7476
Inc file was updated against
@@ -77,6 +79,16 @@ interface
7779
{$I SDL_log.inc} // 3.1.6-prev
7880
{$I SDL_version.inc} // 3.1.6-prev
7981
{$I SDL_revision.inc} // 3.1.6-prev
82+
{$I SDL_stdinc.inc} // 3.1.6-prev (unfinished)
83+
{$I SDL_rect.inc} // 3.1.6-prev
84+
{$I SDL_properties.inc} // 3.1.6-prev
85+
{$I SDL_pixels.inc} // 3.1.6-prev
86+
{$I SDL_blendmode.inc} // 3.1.6-prev
87+
{$I SDL_iostream.inc} // 3.1.6-prev (unfinished)
88+
{$I SDL_surface.inc} // 3.1.6-prev
89+
{$I SDL_video.inc} // 3.1.6-prev
90+
{$I SDL_render.inc} // 3.1.6-prev
91+
8092

8193
implementation
8294

@@ -114,5 +126,81 @@ function SDL_VERSION_ATLEAST(X, Y, Z: Integer): Boolean;
114126
Result:=False;
115127
end;
116128

129+
{ Macros from SDL_rect.h }
130+
procedure SDL_RectToFRect(const rect: PSDL_Rect; frect: PSDL_FRect);
131+
begin
132+
frect^.x:=cfloat(rect^.x);
133+
frect^.y:=cfloat(rect^.y);
134+
frect^.w:=cfloat(rect^.w);
135+
frect^.h:=cfloat(rect^.h);
136+
end;
137+
138+
function SDL_PointInRect(const p: PSDL_Point; const r: PSDL_Rect): cbool;
139+
begin
140+
Result :=
141+
(p <> nil) and (r <> nil) and (p^.x >= r^.x) and (p^.x < (r^.x + r^.w)) and
142+
(p^.y >= r^.y) and (p^.y < (r^.y + r^.h));
143+
end;
144+
145+
function SDL_RectEmpty(const r: PSDL_Rect): cbool;
146+
begin
147+
Result := (r = nil) or (r^.w <= 0) or (r^.h <= 0);
148+
end;
149+
150+
function SDL_RectsEqual(const a: PSDL_Rect; const b: PSDL_Rect): cbool;
151+
begin
152+
Result := (a <> nil) and (b <> nil) and (a^.x = b^.x) and (a^.y = b^.y) and
153+
(a^.w = b^.w) and (a^.h = b^.h);
154+
end;
155+
156+
function SDL_PointInRectFloat(const p: PSDL_FPoint; const r: PSDL_FRect): cbool;
157+
begin
158+
Result :=
159+
(p <> nil) and (r <> nil) and (p^.x >= r^.x) and (p^.x <= (r^.x + r^.w)) and
160+
(p^.y >= r^.y) and (p^.y <= (r^.y + r^.h));
161+
end;
162+
163+
function SDL_RectEmptyFloat(const r: PSDL_FRect): cbool;
164+
begin
165+
Result := (r = nil) or (r^.w < cfloat(0.0)) or (r^.h < cfloat(0.0));
166+
end;
167+
168+
function SDL_RectsEqualEpsilon(const a: PSDL_Frect; const b: PSDL_FRect;
169+
const epsilon: cfloat): cbool;
170+
begin
171+
Result :=
172+
(a <> nil) and (b <> nil) and ((a = b) or
173+
((SDL_fabsf(a^.x - b^.x) <= epsilon) and
174+
(SDL_fabsf(a^.y - b^.y) <= epsilon) and
175+
(SDL_fabsf(a^.w - b^.w) <= epsilon) and
176+
(SDL_fabsf(a^.h - b^.h) <= epsilon)));
177+
end;
178+
179+
function SDL_RectsEqualFloat(const a: PSDL_FRect; b: PSDL_FRect): cbool;
180+
begin
181+
Result := SDL_RectsEqualEpsilon(a, b, SDL_FLT_EPSILON);
182+
end;
183+
184+
{ Macros from SDL_video.h }
185+
function SDL_WINDOWPOS_UNDEFINED_DISPLAY(X: Integer): Integer;
186+
begin
187+
Result := (SDL_WINDOWPOS_CENTERED_MASK or X);
188+
end;
189+
190+
function SDL_WINDOWPOS_ISUNDEFINED(X: Integer): Boolean;
191+
begin
192+
Result := (X and $FFFF0000) = SDL_WINDOWPOS_UNDEFINED_MASK;
193+
end;
194+
195+
function SDL_WINDOWPOS_CENTERED_DISPLAY(X: Integer): Integer;
196+
begin
197+
Result := (SDL_WINDOWPOS_CENTERED_MASK or X);
198+
end;
199+
200+
function SDL_WINDOWPOS_ISCENTERED(X: Integer): Boolean;
201+
begin
202+
Result := (X and $FFFF0000) = SDL_WINDOWPOS_CENTERED_MASK;
203+
end;
204+
117205
end.
118206

0 commit comments

Comments
 (0)