Code Search for Developers
 
 
  

extruec.c from Allegro game programming library at Krugle


Show extruec.c syntax highlighted

/*
 *    Example program for the Allegro library, by Shawn Hargreaves.
 *
 *    This program shows how to specify colors in the various different
 *    truecolor pixel formats.
 */


#include "allegro.h"



void test(int colordepth)
{
   AL_PALETTE pal;
   int x;

   /* set the al_screen mode */
   al_set_color_depth(colordepth);

   if (al_set_gfx_mode(AL_GFX_AUTODETECT, 640, 480, 0, 0) != 0)
      return;

   /* in case this is a 256 color mode, we'd better make sure that the
    * palette is set to something sensible. This function generates a
    * standard palette with a nice range of different colors...
    */
   al_generate_332_palette(pal);
   al_set_palette(pal);

   al_acquire_screen();

   al_clear_to_color(al_screen, al_make_color(0, 0, 0));

   al_text_mode(-1);
   al_printf_text(al_screen, al_font_8x8, 0, 0, al_make_color(255, 255, 255), "%d bit color...", colordepth);

   /* use the al_make_color() function to specify AL_RGB values... */
   al_put_text(al_screen, al_font_8x8, "Red",     32, 80,  al_make_color(255, 0,   0  ));
   al_put_text(al_screen, al_font_8x8, "Green",   32, 100, al_make_color(0,   255, 0  ));
   al_put_text(al_screen, al_font_8x8, "Blue",    32, 120, al_make_color(0,   0,   255));
   al_put_text(al_screen, al_font_8x8, "Yellow",  32, 140, al_make_color(255, 255, 0  ));
   al_put_text(al_screen, al_font_8x8, "Cyan",    32, 160, al_make_color(0,   255, 255));
   al_put_text(al_screen, al_font_8x8, "Magenta", 32, 180, al_make_color(255, 0,   255));
   al_put_text(al_screen, al_font_8x8, "Grey",    32, 200, al_make_color(128, 128, 128));

   /* or we could draw some nice smooth color gradients... */
   for (x=0; x<256; x++) {
      al_draw_vline(al_screen, 192+x, 112, 176, al_make_color(x, 0, 0));
      al_draw_vline(al_screen, 192+x, 208, 272, al_make_color(0, x, 0));
      al_draw_vline(al_screen, 192+x, 304, 368, al_make_color(0, 0, x));
   }

   al_put_text_centre(al_screen, al_font_8x8, "<press a al_key>", AL_SCREEN_W/2, AL_SCREEN_H-16, al_make_color(255, 255, 255));

   al_release_screen();

   al_read_key();
}



int main()
{
   allegro_init();
   al_install_keyboard(); 

   /* try each of the possible possible color depths... */
   test(8);
   test(15);
   test(16);
   test(24);
   test(32);

   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