Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - fg_setpalette http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                              fg_setpalette

   Usage
   #include <fg.h>
   void   far   fg_setpalette(fg_color_t   color_num,   fg_color_t   red,
   fg_color_t green, fg_color_t blue);

   Description
   Set the palette for display adaptors where fg.nsimulcolor is not equal
   to fg.ncolormap.

   Set  the  palette  for the VGA/EGA. color_num is a number  from  0  to
   fg.nsimulcolor  that is desired to have the specified red, green,  and
   blue intensities. The range of 'red', 'green', and 'blue' is from 0 to
   255.  For graphics boards that have only 16 shades of red,  green  and
   blue  the  range  of  0 to 255 is  divided  evenly  among  the  colors
   available. For example the EGA has a total palette of 64, there are  4
   different  intensities  for each of the 3 colors (cube  root  of  64).
   Therefore for red in the range of 0 to 63 will be the same as 0, 64 to
   127  is the same as 64, 128 to 191 is the same as 128, and 192 to  255
   is the same as 192.

   All pixels that use the color'color_l now have the relative proportion
   of red, green, and blue specified. This applies to pixels presently on
   the  screen drawn with 'color_num' as well as subsequent pixels  drawn
   with that color.

   Example
   /* Initialize the vga palette for mode 0x13. */

   void init_vga13_palette(void)
   {
   int color_num, gray, red, green, blue;

        color_num = 0;
                                      /* Set the gray scale. */
        for (gray = 0; color_num 40; gray += 6)
             fg_setpalette(color_num++, gray, gray, gray);

        for (red = 0; red 256; red += 51)
        {
             for (green = 0; green 256; green += 51)
             {
                  for (blue = 0; blue 256; blue += 51)
                       fg_setpalette(color_num++, red, green, blue);
             }
        }
   }


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson