1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/*
* 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 screen.
*/
#include "allegro.h"
int main()
{
BITMAP *memory_bitmap;
int x, y;
allegro_init();
install_keyboard();
if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
return 1;
}
set_palette(desktop_palette);
/* make a memory bitmap sized 20x20 */
memory_bitmap = create_bitmap(20, 20);
/* draw some circles onto it */
clear_bitmap(memory_bitmap);
for (x=0; x<16; x++)
circle(memory_bitmap, 10, 10, x, palette_color[x]);
/* blit lots of copies of it onto the screen */
acquire_screen();
for (y=0; y<SCREEN_H; y+=20)
for (x=0; x<SCREEN_W; x+=20)
blit(memory_bitmap, screen, 0, 0, x, y, 20, 20);
release_screen();
/* free the memory bitmap */
destroy_bitmap(memory_bitmap);
readkey();
return 0;
}
END_OF_MAIN();
|