Code Search for Developers
 
 
  

exdata.c from Allegro game programming library at Krugle


Show exdata.c syntax highlighted

/*
 *    Example program for the Allegro library, by Shawn Hargreaves.
 *
 *    This program demonstrates how to access the contents of an
 *    Allegro datafile (created by the grabber utility).
 */


#include "allegro.h"


/* the grabber produces this header, which contains defines for the names
 * of all the objects in the datafile (BIG_FONT, SILLY_BITMAP, etc).
 */
#include "example.h"



int main(int argc, char *argv[])
{
   AL_DATAFILE *datafile;
   char buf[256];

   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;
   }

   /* we still don't have a palette => Don't let Allegro twist colors */
   al_set_color_conversion(AL_COLORCONV_NONE);

   /* load the datafile into memory */
   al_replace_filename(buf, argv[0], "example.dat", sizeof(buf));
   datafile = al_load_datafile(buf);
   if (!datafile) {
      al_set_gfx_mode(AL_GFX_NONE, 0, 0, 0, 0);
      al_show_message("Error loading %s!\n", buf);
      return 1;
   }

   /* select the palette which was loaded from the datafile */
   al_set_palette(datafile[THE_PALETTE].dat);

   /* aha, set a palette and let Allegro convert colors when blitting */
   al_set_color_conversion(AL_COLORCONV_TOTAL);
   
   /* display the bitmap from the datafile */
   al_put_text(al_screen, al_font_8x8, "This is the bitmap:", 32, 16, al_make_color(255, 255, 255));
   al_blit(datafile[SILLY_BITMAP].dat, al_screen, 0, 0, 64, 32, 64, 64);

   /* and use the al_font_8x8 from the datafile */
   al_put_text(al_screen, datafile[BIG_FONT].dat, "And this is a big al_font_8x8!", 32, 128,
	   al_make_color(0, 255, 0));

   al_read_key();

   /* unload the datafile when we are finished with it */
   al_destroy_datafile(datafile);

   return 0;
}

AL_END_OF_MAIN();




See more files for this project here

Allegro game programming library

Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming.

Project homepage: http://sourceforge.net/projects/alleg
Programming language(s): Assembly,C,Shell Script
License: other

  allegro.pcx
  ex12bit.c
  ex3buf.c
  ex3d.c
  exaccel.c
  exalpha.c
  example.dat
  example.h
  examples.txt
  exbitmap.c
  exblend.c
  excamera.c
  excolmap.c
  excustom.c
  exdata.c
  exdbuf.c
  exdodgy.c
  exexedat.c
  exfixed.c
  exflame.c
  exflip.c
  exgui.c
  exhello.c
  exjoy.c
  exkeys.c
  exlights.c
  exmem.c
  exmidi.c
  exmouse.c
  expal.c
  expat.c
  exquat.c
  exrgbhsv.c
  exsample.c
  exscale.c
  exscn3d.c
  exscroll.c
  exshade.c
  exspline.c
  exsprite.c
  exstars.c
  exstream.c
  exswitch.c
  extimer.c
  extrans.c
  extruec.c
  exunicod.c
  exupdate.c
  exxfade.c
  exzbuf.c
  mysha.pcx
  planet.pcx
  running.dat
  running.h
  unifont.dat