home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////
- // Game Programming All In One, Third Edition
- // Chapter 3 - DrawBitmap Program
- /////////////////////////////////////////////////////////////////////////
-
- #include <allegro.h>
-
- int main(void)
- {
- char *filename = "allegro.pcx";
- BITMAP *image;
- int ret;
-
- allegro_init();
- install_keyboard();
-
- set_color_depth(16);
- ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
- if (ret != 0) {
- allegro_message(allegro_error);
- return 1;
- }
-
- //load the image file
- image = load_bitmap(filename, NULL);
- if (!image) {
- set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
- allegro_message("Error loading %s", filename);
- return 1;
- }
-
- //display the image
- blit(image, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
-
- //done drawing--delete bitmap from memory
- destroy_bitmap(image);
-
- //display video mode information
- textprintf_ex(screen,font,0,0,1,-1,"%dx%d",SCREEN_W,SCREEN_H);
-
- //wait for keypress
- while (!keypressed());
-
- //exit program
- allegro_exit();
- return 0;
- }
-
- END_OF_MAIN()
-
-