home *** CD-ROM | disk | FTP | other *** search
/ Game Programming - All in One (3rd Edition) / game_prog_all_in_one_3rd_ed.iso / sources / chapter03 / DrawBitmap / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  2006-09-10  |  1.2 KB  |  51 lines

  1. /////////////////////////////////////////////////////////////////////////
  2. // Game Programming All In One, Third Edition
  3. // Chapter 3 - DrawBitmap Program
  4. /////////////////////////////////////////////////////////////////////////
  5.  
  6. #include <allegro.h>
  7.  
  8. int main(void)
  9. {
  10.     char *filename = "allegro.pcx";
  11.     BITMAP *image;
  12.     int ret;
  13.  
  14.     allegro_init(); 
  15.     install_keyboard(); 
  16.  
  17.     set_color_depth(16);
  18.     ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
  19.     if (ret != 0) {
  20.         allegro_message(allegro_error);
  21.         return 1;
  22.     }
  23.  
  24.     //load the image file
  25.     image = load_bitmap(filename, NULL);
  26.     if (!image) {
  27.         set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
  28.         allegro_message("Error loading %s", filename);
  29.         return 1;
  30.     }
  31.  
  32.     //display the image
  33.     blit(image, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
  34.  
  35.     //done drawing--delete bitmap from memory
  36.     destroy_bitmap(image);
  37.  
  38.     //display video mode information
  39.     textprintf_ex(screen,font,0,0,1,-1,"%dx%d",SCREEN_W,SCREEN_H);
  40.  
  41.     //wait for keypress
  42.     while (!keypressed());
  43.  
  44.     //exit program
  45.     allegro_exit();
  46.     return 0;
  47. }
  48.  
  49. END_OF_MAIN()
  50.  
  51.