A Short Allegro Program for Testing

Here we give a short program that uses the Allegro library, so that you can verify that everything is set up correctly. The program draws a grey circle in the upper left part of a window. Be careful to not make a mistake when typing in the program. Perhaps. in this special case, it would be the best to copy-paste this program straight from here into your source code file.

#include <allegro.h>

int main()
    if (allegro_init()!=0) return 1;
    if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) !=0 ) 
        return 2;
    BITMAP* surface = create_bitmap(SCREEN_W, SCREEN_H);
    clear_to_color(surface, makecol(255,255,255));
    circlefill(surface, 100, 100, 50, makecol(128,128,128));
    blit(surface, screen, 0,0,0,0,SCREEN_W,SCREEN_H);
    while (!keypressed())
    return 0;
Allegro test program graphics

Notice, when typing in the final line, it does not terminate by a semicolon.

Press the F5 key to run the program and this window should appear.

Press any key to end the execution of this program.