1GLBLENDEQUATION(3G) GLBLENDEQUATION(3G)
2
3
4
6 glBlendEquation - set the blend equation
7
8
10 void glBlendEquation( GLenum mode )
11
12
14 mode specifies how source and destination colors are combined. It
15 must be GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT,
16 GL_MIN, GL_MAX.
17
18
20 The blend equation determines how a new pixel (the ``source'' color) is
21 combined with a pixel already in the framebuffer (the ``destination''
22 color).
23
24 GL_MIN sets the blend equation so that each component of the result
25 color is the minimum of the corresponding components of the
26 source and destination colors.
27
28 GL_MAX sets the blend equation so that each component of the result
29 color is the maximum of the corresponding components of the
30 source and destination colors.
31
32 The remaining blend equations use the source and destination blend fac‐
33 tors specified by glBlendFunc. See glBlendFunc for a description of
34 the various blend factors.
35
36 In the equations that follow, source and destination color components
37 are referred to as (Rs,Gs,Bs,As) and (Rd,Gd,Bd,Ad), respectively. The
38 result color is referred to as (Rr,Gr,Br,Ar). The source and destina‐
39 tion blend factors are denoted (sR,sG,sB,sA) and (dR,dG,dB,dA), respec‐
40 tively. For these equations all color components are understood to
41 have values in the range [0, 1].
42
43 GL_FUNC_ADD
44 sets the blend equation so that the source and destination data
45 are added. Each component of the source color is multiplied by
46 the corresponding source factor, then each component of the des‐
47 tination color is multiplied by the corresponding destination
48 factor. The result is the componentwise sum of the two prod‐
49 ucts, clamped to the range [0, 1].
50
51 Rr=min(1,RssR+RddR)
52 Gr=min(1,GssG+GddG)
53 Br=min(1,BssB+BddB)
54 Ar=min(1,AssA+AddA)
55
56 GL_FUNC_SUBTRACT
57 Is like GL_FUNC_ADD except the product of the destination factor
58 and the destination color is componentwise subtracted from the
59 product of the source factor and the source color. The result
60 is clamped to the range [0, 1].
61
62 Rr=max(0,RssR−RddR)
63 Gr=max(0,GssG−GddG)
64 Br=max(0,BssB−BddB)
65 Ar=max(0,AssA−AddA)
66
67 GL_FUNC_REVERSE_SUBTRACT
68 Is like GL_FUNC_ADD except the product of the source factor and
69 the source color is componentwise subtracted from the product of
70 the destination factor and the destination color. The result is
71 clamped to the range [0, 1].
72
73 Rr=max(0,RddR−RssR)
74 Gr=max(0,GddG−GssG)
75 Br=max(0,BddB−BssB)
76 Ar=max(0,AddA−AssA)
77
78 The GL_MIN and GL_MAX equations are useful for applications that ana‐
79 lyze
80 image data (image thresholding against a constant color, for example).
81 The GL_FUNC_ADD equation is useful for antialiasing and transparency,
82 among other things.
83
84 Initially, the blend equation is set to GL_FUNC_ADD.
85
87 glBlendEquation is part of the GL_ARB_imaging subset. glBlendEquation
88 is present only if GL_ARB_imaging is returned when glGetString is
89 called with GL_EXTENSIONS as its argument.
90
91 The GL_MIN, and GL_MAX equations do not use the source or destination
92 factors, only the source and destination colors.
93
95 GL_INVALID_ENUM is generated if mode is not one of GL_FUNC_ADD,
96 GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX, or GL_MIN.
97
98 GL_INVALID_OPERATION is generated if glBlendEquation is executed
99 between the execution of glBegin and the corresponding execution of
100 glEnd.
101
103 glGet with an argument of GL_BLEND_EQUATION
104
106 glGetString(3G), glBlendColor(3G), glBlendFunc(3G)
107
108
109
110 GLBLENDEQUATION(3G)