File: extruec.c

package info (click to toggle)
allegro4 2%3A4.0.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 17,052 kB
  • ctags: 12,972
  • sloc: ansic: 109,525; asm: 16,672; cpp: 3,221; sh: 1,761; makefile: 556; pascal: 105; perl: 73
file content (78 lines) | stat: -rw-r--r-- 2,006 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 *    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)
{
   PALETTE pal;
   int x;

   /* set the screen mode */
   set_color_depth(colordepth);

   if (set_gfx_mode(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...
    */
   generate_332_palette(pal);
   set_palette(pal);

   acquire_screen();

   clear_to_color(screen, makecol(0, 0, 0));

   text_mode(-1);
   textprintf(screen, font, 0, 0, makecol(255, 255, 255), "%d bit color...", colordepth);

   /* use the makecol() function to specify RGB values... */
   textout(screen, font, "Red",     32, 80,  makecol(255, 0,   0  ));
   textout(screen, font, "Green",   32, 100, makecol(0,   255, 0  ));
   textout(screen, font, "Blue",    32, 120, makecol(0,   0,   255));
   textout(screen, font, "Yellow",  32, 140, makecol(255, 255, 0  ));
   textout(screen, font, "Cyan",    32, 160, makecol(0,   255, 255));
   textout(screen, font, "Magenta", 32, 180, makecol(255, 0,   255));
   textout(screen, font, "Grey",    32, 200, makecol(128, 128, 128));

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

   textout_centre(screen, font, "<press a key>", SCREEN_W/2, SCREEN_H-16, makecol(255, 255, 255));

   release_screen();

   readkey();
}



int main()
{
   allegro_init();
   install_keyboard(); 

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

   return 0;
}

END_OF_MAIN();