Skip to content

Commit 6061fe3

Browse files
Merge branch 'master' into add-sdlstdinc-character-functions
2 parents 0fe9ab8 + e0a3e70 commit 6061fe3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1970
-458
lines changed

LEGACYCHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ v.1.70-stable; 16.09.2013: Initial Commit
8383
v.1.72-stable; 29.09.2013: fixed bug with procedures without parameters (they must have brackets)
8484

8585
v.1.70-stable; 11.09.2013: Initial Commit
86+
87+
## Extracted from jedi.inc
88+
89+
v. 1.63-stable; 16.09.13: since GPC isn't supported anymore, i've deleted it from here, too.
90+
91+
v. 1.22-alpha; 24.07.13: fixed some bugs. special thanks to kotai from pascalgamedevelopment.com
92+
93+
v. 1.00-alpha; 05.07.13: Initial Alpha-Release

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Unit files for building
44
[Free Pascal](https://freepascal.org/) / [Delphi](https://www.embarcadero.com/products/delphi) applications
55
using the [SDL2 library](https://libsdl.org).
66

7-
This repository is a community-maintained fork of the [Pascal-SDL-2-Headers](https://github.com/ev1313/Pascal-SDL-2-Headers) repo.
7+
The [SDL2-for-Pascal](https://github.com/PascalGameDevelopment/SDL2-for-Pascal) repository is a community-maintained fork of the [Pascal-SDL-2-Headers](https://github.com/ev1313/Pascal-SDL-2-Headers) repository.
88

99
## Installation
1010

@@ -20,11 +20,21 @@ Use the `sdl2` unit for the main SDL2 library (should be always needed). Units f
2020
- [`sdl2_net`](https://www.libsdl.org/projects/SDL_net/)
2121
- [`sdl2_ttf`](https://www.libsdl.org/projects/SDL_ttf/)
2222

23+
## Documentation
24+
25+
[Official SDL2-for-Pascal Documentation](https://pascalgamedevelopment.github.io/SDL2-for-Pascal)
26+
27+
### Further Resources
28+
29+
[Free Pascal meets SDL](https://www.freepascal-meets-sdl.net)
30+
31+
[PGD SDL2 Forum](https://www.pascalgamedevelopment.com/forumdisplay.php?26-SDL-SDL-2)
32+
2333
## Bugs / Contributions / ToDos
2434

2535
If you have any contributions or bugfixes, feel free to drop a pull request or send in a patch.
36+
Please use the GitHub [issue tracker](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues).
2637

27-
Please use the GitHub issue tracker for bug reports.
2838

2939
### ToDos
3040

@@ -34,7 +44,7 @@ See part Enums on the [Cheat sheet](CHEATSHEET.md) for reference.
3444
- (Continously) improve Delphi-compatibility (and even more important, DO NOT break it)
3545
- (Continously) Adapt comments to [PasDoc format](https://pasdoc.github.io). (See issue [#22](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/22))
3646

37-
## Code style guidelines
47+
### Code style guidelines
3848

3949
The main principle is to stay as tight as possible at the names in the C headers.
4050
These guidelines aim to have better consistency in this community project and make
@@ -61,7 +71,9 @@ Exception: Replace `*char` by `PAnsiChar`! (see issue [#26](https://github.com/P
6171

6272
4. If an identifier or a function declaration is gone, mark them as `deprecated`. (see issue [#34](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/34))
6373

64-
5. Have a look at our [Translation Cheat Sheet](CHEATSHEET.md) for reference.
74+
5. For convenience we encourage to add single and double pointers for any SDL type. (See #105)
75+
76+
6. Have a look at our [Translation Cheat Sheet](CHEATSHEET.md) for reference.
6577

6678
## Versions
6779

units/ctypes.inc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
type
2525
DWord = LongWord;
2626

27+
ppcbool = ^pcbool;
2728
pcbool = ^cbool;
2829
cbool = LongBool;
2930
{$EXTERNALSYM cbool}
3031

32+
ppcint8 = ^pcint8;
3133
pcint8 = ^cint8;
3234
cint8 = ShortInt;
3335
{$EXTERNALSYM cint8}
@@ -36,50 +38,60 @@ type
3638
cuint8 = Byte;
3739
{$EXTERNALSYM cuint8}
3840

41+
ppcint16 = ^pcint16;
3942
pcint16 = ^cint16;
4043
cint16 = SmallInt;
4144
{$EXTERNALSYM cint16}
4245

46+
ppcuint16 = ^pcuint16;
4347
pcuint16 = ^cuint16;
4448
cuint16 = Word;
4549
{$EXTERNALSYM cuint16}
4650

51+
ppcushort = ^pcushort;
4752
pcushort = ^cushort;
4853
cushort = Word;
4954
{$EXTERNALSYM cushort}
5055

56+
ppcint32 = ^pcint32;
5157
pcint32 = ^cint32;
5258
cint32 = LongInt;
5359
{$EXTERNALSYM cint32}
5460

61+
ppcuint32 = ^pcuint32;
5562
pcuint32 = ^cuint32;
5663
cuint32 = LongWord;
5764
{$EXTERNALSYM cuint32}
5865

5966
{$IFNDEF Has_Int64}
67+
ppcint64 = ^pcint64;
6068
pcint64 = ^cint64;
6169
cint64 = record
6270
hi: cuint32;
6371
lo: cuint32;
6472
end;
6573
{$EXTERNALSYM cint64}
6674

75+
ppcuint64 = ^pcuint64;
6776
pcuint64 = ^cuint64;
6877
cuint64 = record
6978
hi: cuint32;
7079
lo: cuint32;
7180
end;
7281
{$EXTERNALSYM cuint64}
7382
{$ELSE}
83+
ppcint64 = ^pcint64;
7484
pcint64 = ^cint64;
7585
cint64 = Int64;
7686
{$EXTERNALSYM cint64}
7787

88+
ppcuint64 = ^pcuint64;
7889
pcuint64 = ^cuint64;
7990
cuint64 = UInt64;
8091
{$EXTERNALSYM cuint64}
8192
{$ENDIF}
8293

94+
ppcsize_t = ^pcsize_t;
8395
pcsize_t = ^csize_t;
8496
{$IFNDEF WIN64}
8597
csize_t = cuint32;
@@ -88,13 +100,26 @@ type
88100
{$ENDIF}
89101
{$EXTERNALSYM csize_t}
90102

103+
ppcfloat = ^pcfloat;
91104
pcfloat = ^cfloat;
92105
cfloat = Single;
93106
{$EXTERNALSYM cfloat}
94107

108+
ppcdouble = ^pcdouble;
109+
pcdouble = ^cdouble;
110+
cdouble = Double;
111+
{$EXTERNALSYM cfloat}
112+
113+
ppcint = ^pcint;
95114
pcint = ^cint;
115+
116+
ppcuint = ^pcuint;
96117
pcuint = ^cuint;
118+
119+
ppclong = ^pclong;
97120
pclong = ^clong;
121+
122+
ppculong = ^pculong;
98123
pculong = ^culong;
99124
{
100125
Integer type sizes based on:
@@ -123,6 +148,7 @@ type
123148

124149
{ Data types for all compilers }
125150
type
151+
PPUInt8Array = ^PUInt8Array;
126152
PUInt8Array = ^TUInt8Array;
127153
TUInt8Array = array [0..MAXINT shr 1] of cuint8;
128154

units/jedi.inc

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
{
2-
Simple DirectMedia Layer
3-
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2+
This file (jedi.inc) is part of SDL2-for-Pascal.
3+
It defines some variables for several Pascal-Compilers and OS-versions.
44
5-
Pascal-Header-Conversion
6-
Copyright (c) 2012/13 Tim Blume aka End
5+
It is based upon:
76
8-
sdl.inc is based on the files:
9-
"begin_code.h",
10-
"close_code.h",
11-
"sdl_config.h",
12-
"sdl_config_windows.h",
13-
...
14-
it defines some variables for several Pascal-Compilers and OS-versions.
7+
Pascal-Header-Conversion
8+
Copyright (c) 2012/13 Tim Blume aka End
159
16-
It is based on mine updated version of jedi-sdl.inc from the SDL 1.2 Headers,
17-
they can be found at delphigl.com or on my github-repository:
18-
19-
https://github.com/ev1313/
10+
jedi-sdl.inc: Global Conditional Definitions for JEDI-SDL cross-compilation
11+
Copyright (C) 2000 - 2013 Prof. Abimbola Olowofoyeku and Tim Blume
12+
See: https://github.com/ev1313/
2013
2114
This software is provided 'as-is', without any express or implied
2215
warranty. In no event will the authors be held liable for any damages
@@ -35,14 +28,6 @@
3528
3. This notice may not be removed or altered from any source distribution.
3629
}
3730

38-
{
39-
Changelog:
40-
----------
41-
v. 1.63-stable; 16.09.13: since GPC isn't supported anymore, i've deleted it from here, too.
42-
v. 1.22-alpha; 24.07.13: fixed some bugs. special thanks to kotai from pascalgamedevelopment.com
43-
v. 1.00-alpha; 05.07.13: Initial Alpha-Release
44-
}
45-
4631
{.$define Debug} { uncomment for debugging }
4732

4833
{$IFNDEF FPC}

units/sdl.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// based on "sdl.h"
22

33
type
4+
PPSDL_Init = ^PSDL_Init;
5+
PSDL_Init = ^TSDL_Init;
46
TSDL_Init = type cuint32;
57

68
const

units/sdl2.pas

Lines changed: 33 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,37 @@
11
unit sdl2;
22

33
{
4+
SDL2-for-Pascal
5+
=================
6+
Pascal units for SDL2 - Simple Direct MediaLayer, Version 2
7+
8+
Copyright (C) 2020-2023 PGD Community
9+
Maintainers: M. J. Molski and suve
10+
Visit: https://github.com/PascalGameDevelopment/SDL2-for-Pascal
11+
412
Simple DirectMedia Layer
5-
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
6-
7-
Pascal-Header-Conversion
8-
Copyright (C) 2012-2020 Tim Blume aka End/EV1313
9-
10-
SDL2-for-Pascal
11-
Copyright (C) 2020-2021 PGD Community
12-
13-
SDL.pas is based on the files:
14-
"sdl.h",
15-
"sdl_audio.h",
16-
"sdl_blendmode.h",
17-
"sdl_clipboard.h",
18-
"sdl_cpuinfo.h",
19-
"sdl_events.h",
20-
"sdl_error.h",
21-
"sdl_filesystem.h",
22-
"sdl_gamecontroller.h",
23-
"sdl_gesture.h",
24-
"sdl_haptic.h",
25-
"sdl_hints.h",
26-
"sdl_joystick.h",
27-
"sdl_keyboard.h",
28-
"sdl_keycode.h",
29-
"sdl_loadso.h",
30-
"sdl_log.h",
31-
"sdl_pixels.h",
32-
"sdl_power.h",
33-
"sdl_main.h",
34-
"sdl_messagebox.h",
35-
"sdl_mouse.h",
36-
"sdl_mutex.h",
37-
"sdl_rect.h",
38-
"sdl_render.h",
39-
"sdl_rwops.h",
40-
"sdl_scancode.h",
41-
"sdl_shape.h",
42-
"sdl_stdinc.h",
43-
"sdl_surface.h",
44-
"sdl_system.h",
45-
"sdl_syswm.h",
46-
"sdl_thread.h",
47-
"sdl_timer.h",
48-
"sdl_touch.h",
49-
"sdl_version.h",
50-
"sdl_video.h"
51-
52-
I will not translate:
53-
"sdl_opengl.h",
54-
"sdl_opengles.h"
55-
"sdl_opengles2.h"
13+
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
14+
Visit: http://libsdl.org
5615
57-
cause there's a much better OpenGL-Header avaible at delphigl.com:
16+
SDL2-for-Pascal is based upon:
5817
59-
the dglopengl.pas
18+
Pascal-Header-Conversion
19+
Copyright (C) 2012-2020 Tim Blume aka End/EV1313
6020
61-
You'll find it nowadays here: https://github.com/SaschaWillems/dglOpenGL
21+
JEDI-SDL : Pascal units for SDL
22+
Copyright (C) 2000 - 2004 Dominique Louis <Dominique@SavageSoftware.com.au>
6223
63-
Parts of the SDL.pas are from the SDL-1.2-Headerconversion from the JEDI-Team,
64-
written by Domenique Louis and others.
24+
sdl2.pas is based on the C header files in the include folder
25+
of the original Simple DirectMedia Layer repository.
26+
See: https://github.com/libsdl-org/SDL
27+
28+
OpenGL header files are not translated:
29+
"sdl_opengl.h",
30+
"sdl_opengles.h"
31+
"sdl_opengles2.h"
6532
66-
I've changed the names of the dll for 32 & 64-Bit, so theres no conflict
67-
between 32 & 64 bit Libraries.
33+
There is a much better OpenGL-Header avaible at delphigl.com: dglopengl.pas
34+
See: https://github.com/SaschaWillems/dglOpenGL
6835
6936
This software is provided 'as-is', without any express or implied
7037
warranty. In no case will the authors be held liable for any damages
@@ -84,6 +51,7 @@
8451
8552
Special Thanks to:
8653
54+
- Tim Blume and everyone else contributing to the "Pascal-Header-Conversion"
8755
- DelphiGL.com - Community
8856
- Domenique Louis and everyone else from the JEDI-Team
8957
- Sam Latinga and everyone else from the SDL-Team
@@ -170,7 +138,7 @@ interface
170138
{$I sdlpixels.inc} // 2.0.14 WIP
171139
{$I sdlrect.inc} // 2.24.0
172140
{$I sdlrwops.inc} // 2.0.14
173-
{$I sdlaudio.inc}
141+
{$I sdlaudio.inc} // 2.26.3
174142
{$I sdlblendmode.inc} // 2.0.14
175143
{$I sdlsurface.inc} // 2.0.14
176144
{$I sdlvideo.inc} // 2.24.0
@@ -291,7 +259,6 @@ function SDL_FRectEmpty(const r: PSDL_FRect): Boolean;
291259
Result := (r = NIL) or (r^.w <= cfloat(0.0)) or (r^.h <= cfloat(0.0))
292260
end;
293261

294-
{ FIXME: This the Pascal System.Abs() function, instead of the C SDL_fabsf() function. }
295262
function SDL_FRectEqualsEpsilon(const a, b: PSDL_FRect; const epsilon: cfloat): Boolean;
296263
begin
297264
Result :=
@@ -301,13 +268,13 @@ function SDL_FRectEqualsEpsilon(const a, b: PSDL_FRect; const epsilon: cfloat):
301268
(a = b)
302269
or
303270
(
304-
(Abs(a^.x - b^.x) <= epsilon)
271+
(SDL_fabsf(a^.x - b^.x) <= epsilon)
305272
and
306-
(Abs(a^.y - b^.y) <= epsilon)
273+
(SDL_fabsf(a^.y - b^.y) <= epsilon)
307274
and
308-
(Abs(a^.w - b^.w) <= epsilon)
275+
(SDL_fabsf(a^.w - b^.w) <= epsilon)
309276
and
310-
(Abs(a^.h - b^.h) <= epsilon)
277+
(SDL_fabsf(a^.h - b^.h) <= epsilon)
311278
)
312279
)
313280
end;
@@ -344,9 +311,9 @@ procedure SDL_CompilerBarrier();
344311

345312
//from "sdl_audio.h"
346313

347-
function SDL_LoadWAV(_file: PAnsiChar; spec: PSDL_AudioSpec; audio_buf: ppcuint8; audio_len: pcuint32): PSDL_AudioSpec;
314+
function SDL_LoadWAV(file_: PAnsiChar; spec: PSDL_AudioSpec; audio_buf: ppcuint8; audio_len: pcuint32): PSDL_AudioSpec;
348315
begin
349-
Result := SDL_LoadWAV_RW(SDL_RWFromFile(_file, 'rb'), 1, spec, audio_buf, audio_len);
316+
Result := SDL_LoadWAV_RW(SDL_RWFromFile(file_, 'rb'), 1, spec, audio_buf, audio_len);
350317
end;
351318

352319
function SDL_AUDIO_BITSIZE(x: Cardinal): Cardinal;

units/sdl2_image.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ function IMG_Linked_Version: PSDL_Version cdecl; external IMG_LibName {$IFDEF DE
9090
IMG_INIT_WEBP = $00000008;
9191

9292
type
93+
PPIMG_InitFlags = ^PIMG_InitFlags;
94+
PIMG_InitFlags = ^TIMG_InitFlags;
9395
TIMG_InitFlags = DWord;
9496

9597
{* Loads dynamic libraries and prepares them for use. Flags should be

0 commit comments

Comments
 (0)