See readme.txt for a general introduction, copyright details, and information about how to install Allegro and link your program with it.
The available system ID codes will vary from one platform to another, but you will almost always want to pass SYSTEM_AUTODETECT. Alternatively, SYSTEM_NONE installs a stripped down version of Allegro that won't even try to touch your hardware or do anything platform specific: this can be useful for situations where you only want to manipulate memory bitmaps, such as the text mode datafile tools or the Windows GDI interfacing functions.
The `errno_ptr' and `atexit_ptr' parameters should point to the errno variable and atexit function from your libc: these are required because when Allegro is linked as a DLL, it doesn't have direct access to your local libc data. `atexit_ptr' may be NULL, in which case it is your responsibility to call allegro_exit() manually. Example:
install_allegro(SYSTEM_AUTODETECT, &errno, atexit);
Return value: This function returns zero on success and non-zero on failure (e.g. no system driver could be used). Note: in previous versions of Allegro this function would abort on error.
See also: allegro_init, allegro_exit, set_uformat.
See also: install_allegro, allegro_exit.
Examples using this: Available Allegro examples.
Note that after you call this function, other functions like destroy_bitmap() will most likely crash. This is a problem for C++ global destructors, which usually get called after atexit(), so don't put Allegro calls in them. You can write the destructor code in another method which you can manually call before your program exits, avoiding this problem.
See also: install_allegro, allegro_init, destroy_bitmap.
Examples using this: ex3d, exscn3d, exswitch, exxfade, exzbuf.
int main(void)
{
allegro_init();
/* more stuff goes here */
...
return 0;
}
END_OF_MAIN()
See also: Windows specifics, Unix specifics, MacOS X specifics, Differences between platforms.
Examples using this: Available Allegro examples.
See also: set_gfx_mode, install_sound.
Examples using this: Available Allegro examples.
OSTYPE_UNKNOWN - unknown, or regular MSDOS
OSTYPE_WIN3 - Windows 3.1 or earlier
OSTYPE_WIN95 - Windows 95
OSTYPE_WIN98 - Windows 98
OSTYPE_WINME - Windows ME
OSTYPE_WINNT - Windows NT
OSTYPE_WIN2000 - Windows 2000
OSTYPE_WINXP - Windows XP
OSTYPE_OS2 - OS/2
OSTYPE_WARP - OS/2 Warp 3
OSTYPE_DOSEMU - Linux DOSEMU
OSTYPE_OPENDOS - Caldera OpenDOS
OSTYPE_LINUX - Linux
OSTYPE_SUNOS - SunOS/Solaris
OSTYPE_FREEBSD - FreeBSD
OSTYPE_NETBSD - NetBSD
OSTYPE_IRIX - IRIX
OSTYPE_DARWIN - Darwin
OSTYPE_QNX - QNX
OSTYPE_UNIX - Unknown Unix variant
OSTYPE_BEOS - BeOS
OSTYPE_MACOS - MacOS
OSTYPE_MACOSX - MacOS X
See also: allegro_init, os_version, os_multitasking.
See also: os_type, os_multitasking.
See also: os_type, os_version.
Examples using this: exdodgy.
ret = allegro_init();
if (ret != 0) {
allegro_message("Sorry, couldn't init Allegro (%d).\n", ret);
exit(ret);
}
See also: set_uformat.
Examples using this: Available Allegro examples.
See also: set_close_button_callback, set_uformat.
Examples using this: exunicod.
This function should not generally attempt to exit the program or save any data itself. The function could be called at any time, and there is usually a risk of conflict with the main thread of the program. Instead, you should set a flag during this function, and test it on a regular basis in the main loop of the program.
Pass NULL as the `proc' argument to this function to disable the close button functionality, which is the default state.
Note that Allegro cannot intercept the close button of a DOS box in Windows.
Return value: Returns zero on success and non-zero on failure (e.g. the feature is not supported by the platform).
See also: set_window_title.
Under some OSes, switching to a full screen graphics mode may automatically change the desktop color depth. You have, therefore, to call this function before setting any graphics mode in order to retrieve the real desktop color depth. Example:
allegro_init();
...
if ((depth = desktop_color_depth()) != 0) {
set_color_depth(depth);
}
Return value: Returns the color depth or zero on platforms where this information is not available or does not apply.
See also: get_desktop_resolution, set_color_depth, set_gfx_mode.
Under some OSes, switching to a full screen graphics mode may automatically change the desktop resolution. You have, therefore, to call this function before setting any graphics mode in order to retrieve the real desktop resolution. Example:
int width, height;
allegro_init();
...
if (get_desktop_resolution(&width, &height) == 0) {
/* Got the resolution correctly */
}
Return value: Returns zero on success, or a negative number if this information is not available or does not apply, in which case the values stored in the variables you provided for `width' and `height' are undefined.
See also: desktop_color_depth, set_gfx_mode.
Note that calling this inside your active game loop is a very bad idea, you never know when the OS will give you the CPU back, so you could end up missing the vertical retrace and skipping frames.
See also: vsync.
See also: cpu_vendor, cpu_family, cpu_model, cpu_capabilities, allegro_init.
See also: check_cpu, cpu_family, cpu_model, cpu_capabilities, allegro_init.
See also: check_cpu, cpu_vendor, cpu_model, cpu_capabilities, allegro_init.
See also: check_cpu, cpu_vendor, cpu_family, cpu_capabilities, allegro_init.
CPU_ID - Indicates that the "cpuid" instruction is
available. If this is set, then all Allegro CPU
variables are 100% reliable, otherwise there
may be some mistakes.
CPU_FPU - An x87 FPU is available.
CPU_MMX - Intel MMX instruction set is available.
CPU_MMXPLUS - Intel MMX+ instruction set is available.
CPU_SSE - Intel SSE instruction set is available.
CPU_SSE2 - Intel SSE2 instruction set is available.
CPU_3DNOW - AMD 3DNow! instruction set is available.
CPU_ENH3DNOW - AMD Enhanced 3DNow! instruction set is
available.
CPU_CMOV - Pentium Pro "cmov" instruction is available.
You can check for multiple features by OR-ing the flags together.
For example, to check if the CPU has an FPU and MMX instructions
available, you'd do:
if ((cpu_capabilities & (CPU_FPU | CPU_MMX)) ==
(CPU_FPU | CPU_MMX)) {
printf("CPU has both an FPU and MMX instructions!\n");
}
You can read this variable after you have called check_cpu() (which is
automatically called by allegro_init()).
See also: check_cpu, cpu_vendor, cpu_family, cpu_model, cpu_capabilities, allegro_init.