An introduction to Allegro: Open Source Game Development
By Shawn Hargreaves

 

 

 

 

Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming. According to the Oxford Companion to Music, Allegro is the Italian for "quick, lively, bright". It is also a recursive acronym which stands for "Allegro Low Level Game Routines". It was initially conceived on the Atari ST, but that platform sadly died during childbirth. After a brief stay with Borland C, it was adopted by the fantastic djgpp compiler, where it grew to maturity. In the fullness of time it gave birth to children of its own, who went to live in such exotic locations as DirectX and the X Server, but the entire family is now back together again, living in harmony as a single portable entity. How about that for a mixture of metaphors? A wide range of extension packages and add-on modules are also available, which can be found in the "Library Extensions" section of the Allegro website, http://www.talula.demon.co.uk/allegro/.
"According to the Oxford Companion to Music, Allegro is the Italian for "quick, lively, bright". It is also a recursive acronym which stands for 'Allegro Low Level Game Routines' "

Allegro features cross-platform support for DOS, Windows, Unix, and BeOS systems. Drawing functions including putpixel, getpixel, lines, rectangles, flat shaded, gouraud shaded, and texture mapped polygons, circles, floodfill, bezier splines, patterned fills, masked, run length encoded, and compiled sprites, blitting, bitmap scaling and rotation, translucency/lighting, and text output with proportional fonts. It supports clipping, and can draw directly to the screen or to memory bitmaps of any size. Additional video hardware support is available from the FreeBE/AF project (http://www.talula.demon.co.uk/freebe/).

Allegro include support for VGA mode 13h, mode-X (twenty three tweaked VGA resolutions plus unchained 640x400 Xtended mode), and SVGA modes with 8, 15, 16, 24, and 32 bit color depths, taking full advantage of VBE 2.0 linear framebuffers and the VBE/AF hardware accelerator API if they are available. Windows graphics drivers using DirectX in fullscreen and windowed modes are also supported, as well as routines for drawing onto GDI device contexts. Unix graphics drivers are supported for X, DGA, fbcon, GGI, SVGAlib, VBE/AF, mode-X, and standard VGA. Hardware scrolling and triple buffering (where available), mode-X split screens, and palette manipulation, as is FLI/FLC animation player.

Allegro plays background MIDI music and up to 64 simultaneous sound effects, and can record sample waveforms and MIDI input. Samples can be looped (forwards, backwards, or bidirectionally), and the volume, pan, pitch, etc, can be adjusted while they are playing. The MIDI player responds to note on, note off, main volume, pan, pitch bend, and program change messages, using the General MIDI patch set and drum mappings. The DOS version currently supports Adlib, SB, SB Pro, SB16, AWE32, MPU-401, ESS AudioDrive, Ensoniq Soundscape, and Windows Sound System. The Windows version uses DirectSound and the system MIDI drivers. The Unix version supports OSS, ESD, and ALSA sound drivers. All versions provide software wavetable MIDI playback.

Additionally, easy access to the mouse, keyboard, joystick, and high resolution timer interrupts are part of the package, including a vertical retrace interrupt simulator in the DOS version, routines for reading and writing LZSS compressed files, multi-object data files and a grabber utility. Math functions including fixed point arithmetic, lookup table trig, and 3d vector/matrix/quaternion manipulation. There is a GUI dialog manager and file selector.

Allegro is gift-ware. It was created by a number of people working in cooperation, and is given to you freely as a gift. You may use, modify, redistribute, and generally hack it about in any way you like, and you do not have to give the makers anything in return. However, if you like this product you are encouraged to thank them by making a return gift to the Allegro community. This could be by writing an add-on package, providing a useful bug report, making an improvement to the library, or perhaps just releasing the sources of your program so that other people can learn from them. If you redistribute parts of this code or make a game using it, it would be nice if you mentioned Allegro somewhere in the credits, but you are not required to do this.

The latest version of Allegro can always be found on the Allegro homepage, http://www.talula.demon.co.uk/allegro/.

Shawn Hargreaves wrote the core parts of Allegro while earning a music degree at York University. Although he doesn't have any formal computer training other than having done a computing A-level course, which was "incredibly boring", he's been programming for years before this, first on the Oric Atmos (in BASIC and 6502 asm), and later on the Atari ST (Forth, C, and 68000 asm). Since graduation, he's been working for Probe Entertainment (a subsiduary of Acclaim), helping to develop the racing games Extreme-G and XG2 on the N64. As of a few months ago, he has moved to Climax Studios' new Brighton, England office, where he's the lead programmer on a new PS2 title.

Check out

an Allegro Discussion
about Lighting Techniques