All the Allegro drawing functions use integer parameters to represent colors. In truecolor resolutions these numbers encode the color directly as a collection of red, green, and blue bits, but in a regular 256-color mode the values are treated as indexes into the current palette, which is a table listing the red, green and blue intensities for each of the 256 possible colors.
Palette entries are stored in an RGB structure, which contains red, green and blue intensities in the VGA hardware format, ranging from 0-63, and is defined as:
It contains an additional field for the purpose of padding but you should not usually care about it. For example:typedef struct RGB { unsigned char r, g, b; } RGB;
The type PALETTE is defined to be an array of PAL_SIZE RGB structures, where PAL_SIZE is a preprocessor constant greater or equal to 256.RGB black = { 0, 0, 0 }; RGB white = { 63, 63, 63 }; RGB green = { 0, 63, 0 }; RGB grey = { 32, 32, 32 };
You may notice that a lot of the code in Allegro spells 'palette' as 'pallete'. This is because the headers from my old Mark Williams compiler on the Atari spelt it with two l's, so that is what I'm used to. Allegro will happily accept either spelling, due to some #defines in allegro/alcompat.h (which can be turned off by defining the ALLEGRO_NO_COMPATIBILITY symbol before including Allegro headers).
RGB rgb; ... vsync(); set_color(192, &rgb);
See also: set_palette, get_color, _set_color.
Examples using this: ex12bit, exrgbhsv, exscroll.
If you really must use _set_color from retrace_proc, note that it should only be used under DOS, in VGA mode 13h and mode-X. Some SVGA chipsets aren't VGA compatible (set_color() and set_palette() will use VESA calls on these cards, but _set_color() doesn't know about that).
See also: set_color, set_gfx_mode.
Examples using this: ex3buf.
BITMAP *bmp; PALETTE palette; ... bmp = load_bitmap(filename, palette); if (!bmp) abort_on_error("Couldn't load bitmap!"); set_palette(palette);
See also: set_gfx_mode, set_palette_range, set_color, get_palette, select_palette, palette_color.
Examples using this: Available Allegro examples.
PALETTE palette; ... change_first_16_colors(palette); /* Change first colors waiting for vsync. */ set_palette_range(palette, 0, 15, 1);
See also: set_palette, get_palette_range.
RGB color; ... get_color(11, &color);
See also: get_palette, set_color.
PALETTE pal; ... get_palette(pal);
See also: get_palette_range, get_color, set_palette.
See also: get_palette, set_palette_range.
See also: fade_in, fade_out, fade_from.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_from.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_in.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_out.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_in, fade_out, fade_interpolate, fade_from_range.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_out, fade_from, fade_interpolate, fade_in_range.
Note that this function will block your game while the fade is in effect, and it won't work right visually if you are not in an 8 bit color depth resolution.
See also: fade_in, fade_from, fade_interpolate, fade_in_range.
Examples using this: ex12bit.
See also: set_palette, unselect_palette.
Examples using this: exlights.
See also: select_palette.
See also: generate_optimized_palette, set_color_depth.
Examples using this: excolmap, exrgbhsv, extruec, exupdate.
See also: generate_332_palette, set_color_depth.
See also: black_palette, desktop_palette.
Examples using this: exjoy.
See also: default_palette, desktop_palette.
Examples using this: expal.
See also: default_palette, black_palette.
Examples using this: Available Allegro examples.