Show exhello.c syntax highlighted
/*
* Example program for the Allegro library, by Shawn Hargreaves.
*
* This is a very simple program showing how to get into graphics
* mode and draw text onto the al_screen.
*/
#include "allegro.h"
int main()
{
/* you should always do this at the start of Allegro programs */
allegro_init();
/* set up the keyboard handler */
al_install_keyboard();
/* set a graphics mode sized 320x200 */
if (al_set_gfx_mode(AL_GFX_SAFE, 320, 200, 0, 0) != 0) {
al_set_gfx_mode(AL_GFX_NONE, 0, 0, 0, 0);
al_show_message("Unable to set any graphic mode\n%s\n", al_error);
return 1;
}
/* set the color palette */
al_set_palette(al_desktop_palette);
/* clear the al_screen to white */
al_clear_to_color(al_screen, al_make_color(255, 255, 255));
/* you don't need to do this, but on some platforms (eg. Windows) things
* will be drawn more quickly if you always acquire the al_screen before
* trying to draw onto it.
*/
al_acquire_screen();
/* set transparent text */
al_text_mode(-1);
/* write some text to the al_screen with black letters */
al_put_text_centre(al_screen, al_font_8x8, "Hello, world!", AL_SCREEN_W/2, AL_SCREEN_H/2, al_make_color(0,0,0));
/* you must always release bitmaps before calling any input functions */
al_release_screen();
/* wait for a keypress */
al_read_key();
return 0;
}
AL_END_OF_MAIN();
See more files for this project here