Show exmem.c syntax highlighted
/*
* Example program for the Allegro library, by Shawn Hargreaves.
*
* This program demonstrates the use of memory bitmaps. It creates
* a small temporary bitmap in memory, draws some circles onto it,
* and then blits lots of copies of it onto the al_screen.
*/
#include "allegro.h"
int main()
{
AL_BITMAP *memory_bitmap;
int x, y;
allegro_init();
al_install_keyboard();
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;
}
al_set_palette(al_desktop_palette);
/* make a memory bitmap sized 20x20 */
memory_bitmap = al_create_bitmap(20, 20);
/* draw some circles onto it */
al_clear_bitmap(memory_bitmap);
for (x=0; x<16; x++)
al_draw_circle(memory_bitmap, 10, 10, x, al_palette_color[x]);
/* al_blit lots of copies of it onto the al_screen */
al_acquire_screen();
for (y=0; y<AL_SCREEN_H; y+=20)
for (x=0; x<AL_SCREEN_W; x+=20)
al_blit(memory_bitmap, al_screen, 0, 0, x, y, 20, 20);
al_release_screen();
/* free the memory bitmap */
al_destroy_bitmap(memory_bitmap);
al_read_key();
return 0;
}
AL_END_OF_MAIN();
See more files for this project here