Transparency and patterned drawing
- drawing_mode - Sets the graphics drawing mode.
- xor_mode - Shortcut for toggling xor drawing mode on and off.
- solid_mode - Shortcut for selecting solid drawing mode.
256-color transparency
In paletted video modes, translucency and lighting are implemented with a
64k lookup table, which contains the result of combining any two colors c1
and c2. You must set up this table before you use any of the translucency
or lighting routines. Depending on how you construct the table, a range of
different effects are possible. For example, translucency can be implemented
by using a color halfway between c1 and c2 as the result of the combination.
Lighting is achieved by treating one of the colors as a light level (0-255)
rather than a color, and setting up the table appropriately. A range of
specialised effects are possible, for instance replacing any color with any
other color and making individual source or destination colors completely
solid or invisible. Color mapping tables can be precalculated with the
colormap utility, or generated at runtime. Read chapter "Structures and types
defined by Allegro" for an internal description of the COLOR_MAP structure.
Truecolor transparency
In truecolor video modes, translucency and lighting are implemented by a
blender function of the form:
unsigned long (*BLENDER_FUNC)(unsigned long x, y, n);
For each pixel to be drawn, this routine is passed two color parameters x
and y, decomposes them into their red, green and blue components, combines
them according to some mathematical transformation involving the
interpolation factor n, and then merges the result back into a single
return color value, which will be used to draw the pixel onto
the destination bitmap.
The parameter x represents the blending modifier color and the parameter y
represents the base color to be modified. The interpolation factor n is in
the range [0-255] and controls the solidity of the blending.
When a translucent drawing function is used, x is the color of the source,
y is the color of the bitmap being drawn onto and n is the alpha level
that was passed to the function that sets the blending mode (the RGB triplet
that was passed to this function is not taken into account).
When a lit sprite drawing function is used, x is the color represented by
the RGB triplet that was passed to the function that sets the blending mode
(the alpha level that was passed to this function is not taken into
account), y is the color of the sprite and n is the alpha level that was
passed to the drawing function itself.
Since these routines may be used from various different color depths, there
are three such callbacks, one for use with 15-bit 5.5.5 pixels, one for 16
bit 5.6.5 pixels, and one for 24-bit 8.8.8 pixels (this can be shared
between the 24 and 32-bit code since the bit packing is the same).