1al_set_blender(3)          Library Functions Manual          al_set_blender(3)
2
3
4

NAME

6       al_set_blender
7

SYNOPSIS

9              #include <allegro5/allegro.h>
10
11              void al_set_blender(int op, int src, int dst)
12

DESCRIPTION

14       Sets the function to use for blending for the current thread.
15
16       Blending means, the source and destination colors are combined in draw‐
17       ing operations.
18
19       Assume the source color (e.g.  color of a rectangle to draw,  or  pixel
20       of  a  bitmap  to draw) is given as its red/green/blue/alpha components
21       (if the bitmap has no alpha it always is assumed to be fully opaque, so
22       255  for  8-bit  or  1.0 for floating point): sr, sg, sb, sa.  And this
23       color is drawn to a destination, which already has a color: dr, dg, db,
24       da.
25
26       The conceptional formula used by Allegro to draw any pixel then depends
27       on the op parameter:
28
29       · ALLEGRO_ADD
30
31                 r = dr * dst + sr * src
32                 g = dg * dst + sg * src
33                 b = db * dst + sb * src
34                 a = da * dst + sa * src
35
36       · ALLEGRO_DEST_MINUS_SRC
37
38                 r = dr * dst - sr * src
39                 g = dg * dst - sg * src
40                 b = db * dst - sb * src
41                 a = da * dst - sa * src
42
43       · ALLEGRO_SRC_MINUS_DEST
44
45                 r = sr * src - dr * dst
46                 g = sg * src - dg * dst
47                 b = sb * src - db * dst
48                 a = sa * src - da * dst
49
50       Valid values for src and dst passed to this function are
51
52       · ALLEGRO_ZERO
53
54                 src = 0
55                 dst = 0
56
57       · ALLEGRO_ONE
58
59                 src = 1
60                 dst = 1
61
62       · ALLEGRO_ALPHA
63
64                 src = sa
65                 dst = sa
66
67       · ALLEGRO_INVERSE_ALPHA
68
69                 src = 1 - sa
70                 dst = 1 - sa
71
72       Blending examples:
73
74       So for example, to restore the default  of  using  premultiplied  alpha
75       blending, you would use (pseudo code)
76
77              al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA)
78
79       If you are using non-pre-multiplied alpha, you could use
80
81              al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA)
82
83       Additive blending would be achieved with
84
85              al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE)
86
87       Copying the source to the destination (including alpha) unmodified
88
89              al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO)
90

SEE ALSO

92       al_set_separate_blender(3), al_get_blender(3)
93
94
95
96Allegro reference manual                                     al_set_blender(3)
Impressum