ASFML — Ada's Simple and Fast Multimedia Library
ASFML is an Ada semi-thick binding to the SFML library. It uses Ada types and portable defined types which eliminates the inclusion of Ada interface libraries, but most of the functions are directly imported.
It is written in standard Ada without the use of any specific GNAT extensions, but some indirect dependency could exist through the representation of some types.
The binding is considered complete. Three versions of CSFML have been bound: 1.6, 2.4 and 2.5 (see Releases). The API is considered stable, changes would only be made to fix errors or to upgrade to a new SFML version.
The library has been tested with several GNAT versions and on Windows 10 and Ubuntu Linux 20.04 LTS and 22.04.
Generated API documentation can be consulted online.
The Ada API follows the CSFML interface, but with some changes and additions to ease the use:
- Prefixes in C are converted to simple names inside hierarchical packages. For example, the
SFML/Audio/Music.his transformed into the
createFromFilefunction in the
- Basic data types from
SFML/Config.hare defined in the
- General types at
SFML/Module/Types.hare moved to the package
Moduleis Audio, System, Graphics, Window and Network.
- Defaults are applied to parameters when useful and to approximate the C++ API.
- Functions with
char*parameters are wrapped to do the conversion to standard Ada
- Unicode is supported using
Wide_Wide_Stringin Ada where the C API uses
Compatibility with CSFML releases
The versioning scheme of ASFML follows the one of CSFML for the major and minor numbers; while the patch number is, in principle, independent. This means, for example, that 2.4.x releases are expected to be compatible with all 2.4.x releases of CSFML. Note, however, that some CSFML releases change the API to fix problems with the binding to SFML and they release them as a patch. Consequently, there are cases, like CSFML 2.5.2, which requires a specific patch level of ASFML, in this case, ASFML 2.5.5. When this happens, the Alire dependencies reflect the requirement.
Nevertheless, the usual problems that can be found when doing an heterogeneous linking are only spotted when calling one of the functions having changed between the releases. Otherwise, the incompatibility will be latent.
How to build with Alire
This library is available in Alire so building is as easy as installing Alire and then executing:
alr build asfml
How to build without Alire
Install CSFML following instructions of your platform. For example, under Ubuntu or Debian:
sudo apt-get install gnat gprbuild libcsfml-dev libglu1-mesa-dev
Open a terminal and run this command:
How to use
To compile your program you need to "with" the
asfml.gpr project. Then
you can build using gprbuild.
asfml_opengl.gpr if you are using OpenGL.
Under Windows, you might need to update the path to your libraries in the provided GPR files.
Using Alire, you can add this library to your project as simply as:
alr with asfml
Links to projects using ASFML can be found in the Wiki.