PascalGameDevelopment / SDL2-for-Pascal

Unit files for building Free Pascal and Delphi applications using the SDL2 library
https://pascalgamedevelopment.github.io/SDL2-for-Pascal/
Mozilla Public License 2.0
103 stars 20 forks source link
delphi free-pascal game-development object-pascal pascal sdl2 simple-direct-media-layer

SDL2-for-Pascal

Unit files for building Free Pascal / Delphi applications using the SDL2 library.

The SDL2-for-Pascal repository is a community-maintained fork of the Pascal-SDL-2-Headers repository.

Installation

Simply add the units to your include path. You can achieve this by:

Use the sdl2 unit for the main SDL2 library (should be always needed). Units for the other SDL2 libraries are also provided:

Documentation

Official SDL2-for-Pascal Documentation

Further Resources

Free Pascal meets SDL

PGD SDL2 Forum

Bugs / Contributions / ToDos

If you have any contributions or bugfixes, feel free to drop a pull request or send in a patch. Please use the GitHub issue tracker.

ToDos

Code style guidelines

The main principle is to stay as tight as possible at the names in the C headers. These guidelines aim to have better consistency in this community project and make it easier to find certain code parts in the C headers/Pascal includes. Feel free to discuss or extend these guidelines, use the issue tracker.

  1. Names of C defines (constants) and function parameters shall not be modified or "pascalified" Ex: SDL_INIT_VIDEO does not change into SDLInitVideo.

  2. Names corresponding to reserved key words are kept and an underscore is added. Ex.: type in C function SDL_HasEvent(Uint32 type) changes into type_ in Pascal function SDL_HasEvent(type_: TSDL_EventType).

  3. Use C data types like cuint8, cuint16, cuint32, cint8, cint16, cint32, cfloat and so on if native C data types are used in the original code. Note: For FPC you need to add the unit ctypes to use these C data types. For Delphi we have a temporary solution provided. (see issue #67)

Example: Use cuint32 (if Uint32 is used in the original code) instead of UInt32, Cardinal, LongWord or DWord. Exception: Replace *char by PAnsiChar! (see issue #26)

Hint: Use TSDL_Bool to translate SDL_bool. For macro functions use Boolean. (see issue #30).

  1. If an identifier or a function declaration is gone, mark them as deprecated. (see issue #34)

  2. For convenience we encourage to add single and double pointers for any SDL type. (see issue #105)

  3. Have a look at our Translation Cheat Sheet for reference.

Versions

The version tag (see tags) refers to the version of this translation package SDL2 for Pascal, not the SDL2 library.

v2.x (work in progress)

v2.2 Stable (02/01/2024)

v2.1 Compatibility Release (25/09/2021)

v2.0

License

You may license the Pascal SDL2 units either with the MPL license or with the zlib license.