These functions are declared in the main Allegro header file:
bool al_install_system(int version, int (*atexit_ptr)(void (*)(void)))
Initialize the Allegro system. No other Allegro functions can be called before this (with one or two exceptions).
The version field should always be set to ALLEGRO_VERSION_INT.
If atexit_ptr is non-NULL, and if hasn't been done already, al_uninstall_system will be registered as an atexit function.
Returns true if Allegro was successfully initialized by this function call (or already was initialized previously), false if Allegro cannot be used.
See also: al_init
#define al_init() (al_install_system(ALLEGRO_VERSION_INT, atexit))
Like al_install_system, but automatically passes in the version and uses the atexit function visible in the current compilation unit.
See also: al_install_system
Closes down the Allegro system.
Note: al_uninstall_system() can be called without a corresponding al_install_system call, e.g. from atexit().
Returns true if Allegro is initialized, otherwise returns false.
Returns the (compiled) version of the Allegro library, packed into a single integer as groups of 8 bits in the form
(major << 24) | (minor << 16) | (revision << 8) | release.
You can use code like this to extract them:
uint32_t version = al_get_allegro_version(); int major = version >> 24; int minor = (version >> 16) & 255; int revision = (version >> 8) & 255; int release = version & 255;
release number is 0 for an unofficial version and 1 or greater for an official release. For example "5.0.2" would be the (first) official 5.0.2 release while "5.0.2" would be a compile of a version from the "5.0.2" branch before the official release.
ALLEGRO_PATH *al_get_standard_path(int id)
Gets a system path, depending on the
id parameter. Some of these paths may be affected by the organization and application name, so be sure to set those before calling this function.
The paths are not guaranteed to be unique (e.g., SETTINGS and DATA may be the same on some platforms), so you should be sure your filenames are unique if you need to avoid naming collisions. Also, a returned path may not actually exist on the file system.
If you bundle data in a location relative to your executable, then you should use this path to locate that data. On most platforms, this is the directory that contains the executable file.
If ran from an OS X app bundle, then this will point to the internal resource directory (
/Contents/Resources). To maintain consistency, if you put your resources into a directory called "data" beneath the executable on some other platform (like Windows), then you should also create a directory called "data" under the OS X app bundle's resource folder.
You should not try to write to this path, as it is very likely read-only.
If you install your resources in some other system directory (e.g., in /usr/share or C:\ProgramData), then you are responsible for keeping track of that yourself.
Path to the directory for temporary files.
This is the user's home directory. You should not normally write files into this directory directly, or create any sub folders in it, without explicit permission from the user. One practical application of this path would be to use it as the starting place of a file selector in a GUI.
This location is easily accessible by the user, and is the place to store documents and files that the user might want to later open with an external program or transfer to another place.
You should not save files here unless the user expects it, usually by explicit permission.
If your program saves any data that the user doesn't need to access externally, then you should place it here. This is generally the least intrusive place to store data.
If you are saving configuration files (especially if the user may want to edit them outside of your program), then you should place them here.
The full path to the executable.
Returns NULL on failure. The returned path should be freed with al_destroy_path.
void al_set_exe_name(char const *path)
This override the executable name used by al_get_standard_path for ALLEGRO_EXENAME_PATH and ALLEGRO_RESOURCES_PATH.
One possibility where changing this can be useful is if you use the Python wrapper. Allegro would then by default think that the system's Python executable is the current executable - but you can set it to the .py file being executed instead.
Since: 5.0.6, 5.1.0
See also: al_get_standard_path
void al_set_app_name(const char *app_name)
Sets the global application name.
The application name is used by al_get_standard_path to build the full path to an application's files.
void al_set_org_name(const char *org_name)
Sets the global organization name.
The organization name is used by al_get_standard_path to build the full path to an application's files.
const char *al_get_app_name(void)
Returns the global application name string.
See also: al_set_app_name
const char *al_get_org_name(void)
Returns the global organization name string.
See also: al_set_org_name
Returns the current system configuration structure, or NULL if there is no active system driver. The returned configuration should not be destroyed with al_destroy_config. This is mainly used for configuring Allegro and its addons.
Allegro will try to populate this configuration by loading a configuration file from a few different locations, in this order:
Unix only: /etc/allegro5rc
Unix only: $HOME/allegro5rc
allegro5.cfg next to the executable
If multiple copies are found, then they are merged using al_merge_config_into.
The contents of this file are documented inside a prototypical allegro5.cfg that you can find in the root directory of the source distributions of Allegro. Note that Allegro will not look into that file unless you make a copy of it and place it next to your executable!
void al_register_assert_handler(void (*handler)(char const *expr, char const *file, int line, char const *func))
Register a function to be called when an internal Allegro assertion fails. Pass NULL to reset to the default behaviour, which is to do whatever the standard
assert() macro does.
Since: 5.0.6, 5.1.0