Screen Update API for Allegro
The accompanying code was written in an attempt to make screen updating using Allegro as easy as possible by writing a small library of functions that could automate the most commonly used screen update methods. This includes initialization, shutdown, the actual drawing and a few minor options. The update methods include standard double buffering methods, drawing directly to video memory for hardware acceleration and "page flipping", and even a combination of the two for things like blending, when reading from the drawing buffer is desirable (this is obviously very slow for video bitmaps). You can even switch update methods on the fly, so the player can select the method that best suits their computer as the program runs.
The API caught the eye of someone relating to work on the core Allegro library, and the API is (AFAIK) planned to be integrated into Allegro itself. Which is very nice; it's the first major contribution I've made to the library, however inadvertantly. However, it's going through some significant changes to fit with where the graphics API is going (Allegro is currently going through an overhaul) and it may be a while until this shows up in a public version. So, here it is for you now in a form very friendly with the current version of Allegro.
The following is a copy of the documentation found in readme.txt. The source files al_screen.h and al_screen.c are all you need to use the API; main.cpp is an example program demonstrating the API's functionality. As a slight bonus, the example program also shows how to use the configuration file routines to store the update method and remember it for the next time the program is run.
int initialize_screen_updating(int i);
UPDATE_TRIPLE_WMB and UPDATE_PAGEFLIP_WMB are for times you're using a lot of blending or whatnot, and don't want your program slowed down due to reading from video memory. UPDATE_SYSTEM_BUFFER and UPDATE_DOUBLE_BUFFER don't synchronize to the vertical retrace of the screen unless vsync is enabled (by calling enable_vsync()). Note that these two mode alone are affected by the vsync functions; the triple buffering and page flipping modes automatically handle vertical retrace synchronisation.
You can call this function multiple times in one program. So if you want the user to be able to switch between update methods to find one best suited to their system, it's as easy as calling initialize_screen_updating() again.
Does what it says. Call this at the end of your program to prevent memory leaks.
Discussion on development of this API can be found here, if you're interested. Hope this was helpful to you.
Chris "23yrold3yrold" Barry