Code Search for Developers
 
 
  

exhello.c from Allegro game programming library at Krugle


Show exhello.c syntax highlighted

/*
 *    Example program for the Allegro library, by Shawn Hargreaves.
 *
 *    This is a very simple program showing how to get into graphics
 *    mode and draw text onto the al_screen.
 */


#include "allegro.h"



int main()
{
   /* you should always do this at the start of Allegro programs */
   allegro_init();

   /* set up the keyboard handler */
   al_install_keyboard(); 

   /* set a graphics mode sized 320x200 */
   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;
   }

   /* set the color palette */
   al_set_palette(al_desktop_palette);

   /* clear the al_screen to white */
   al_clear_to_color(al_screen, al_make_color(255, 255, 255));

   /* you don't need to do this, but on some platforms (eg. Windows) things
    * will be drawn more quickly if you always acquire the al_screen before
    * trying to draw onto it.
    */
   al_acquire_screen();

   /* set transparent text */
   al_text_mode(-1);

   /* write some text to the al_screen with black letters */
   al_put_text_centre(al_screen, al_font_8x8, "Hello, world!", AL_SCREEN_W/2, AL_SCREEN_H/2, al_make_color(0,0,0));

   /* you must always release bitmaps before calling any input functions */
   al_release_screen();

   /* wait for a keypress */
   al_read_key();

   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