1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
'\" te
'\"! tbl|eqn | mmdoc
'\"macro stdmacro
.ds Vn Version 1.2
.ds Dt 24 September 1999
.ds Re Release 1.2.1
.ds Dp Jan 14 18:30
.ds Dm 01 blendfunc
.ds Xs 18970 10 blendfunc.gl
.TH GLBLENDFUNC 3G
.SH NAME
.B "glBlendFunc
\- specify pixel arithmetic
.SH C SPECIFICATION
void \f3glBlendFunc\fP(
GLenum \fIsfactor\fP,
.nf
.ta \w'\f3void \fPglBlendFunc( 'u
GLenum \fIdfactor\fP )
.fi
.EQ
delim $$
.EN
.SH PARAMETERS
.TP \w'\f2sfactor\fP\ \ 'u
\f2sfactor\fP
Specifies how the red, green, blue,
and alpha source blending factors are computed.
The following symbolic constants are accepted:
\%\f3GL_ZERO\fP,
\%\f3GL_ONE\fP,
\%\f3GL_DST_COLOR\fP,
\%\f3GL_ONE_MINUS_DST_COLOR\fP,
\%\f3GL_SRC_ALPHA\fP,
\%\f3GL_ONE_MINUS_SRC_ALPHA\fP,
\%\f3GL_DST_ALPHA\fP,
\%\f3GL_ONE_MINUS_DST_ALPHA\fP, and
\%\f3GL_SRC_ALPHA_SATURATE\fP.
The initial value is \%\f3GL_ONE\fP.
.TE
Additionally, if the \%\f3GL_ARB_imaging\fP extension is supported, the
following constants are accepted:
\%\f3GL_CONSTANT_COLOR\fP,
\%\f3GL_ONE_MINUS_CONSTANT_COLOR\fP,
\%\f3GL_CONSTANT_ALPHA\fP,
\%\f3GL_ONE_MINUS_CONSTANT_ALPHA\fP.
.TP
\f2dfactor\fP
Specifies how the red, green, blue,
and alpha destination blending factors are computed.
Eight symbolic constants are accepted:
\%\f3GL_ZERO\fP,
\%\f3GL_ONE\fP,
\%\f3GL_SRC_COLOR\fP,
\%\f3GL_ONE_MINUS_SRC_COLOR\fP,
\%\f3GL_SRC_ALPHA\fP,
\%\f3GL_ONE_MINUS_SRC_ALPHA\fP,
\%\f3GL_DST_ALPHA\fP, and
\%\f3GL_ONE_MINUS_DST_ALPHA\fP.
The initial value is \%\f3GL_ZERO\fP.
.TE
Additionally, if the \%\f3GL_ARB_imaging\fP extension is supported, the
following constants are accepted:
\%\f3GL_CONSTANT_COLOR\fP,
\%\f3GL_ONE_MINUS_CONSTANT_COLOR\fP,
\%\f3GL_CONSTANT_ALPHA\fP,
\%\f3GL_ONE_MINUS_CONSTANT_ALPHA\fP.
.SH DESCRIPTION
In RGBA mode, pixels can be drawn using a function that blends
the incoming (source) RGBA values with the RGBA values
that are already in the frame buffer (the destination values).
Blending is initially disabled.
Use \%\f3glEnable\fP and \%\f3glDisable\fP with argument \%\f3GL_BLEND\fP
to enable and disable blending.
.P
\%\f3glBlendFunc\fP defines the operation of blending when it is enabled.
\f2sfactor\fP specifies which of nine methods is used to scale the
source color components.
\f2dfactor\fP specifies which of eight methods is used to scale the
destination color components.
The eleven possible methods are described in the following table.
Each method defines four scale factors,
one each for red, green, blue, and alpha.
.P
In the table and in subsequent equations, source and destination
color components are referred to as
$(R sub s , G sub s , B sub s , A sub s )$ and
$(R sub d , G sub d , B sub d , A sub d )$.
The color specified by \%\f3glBlendColor\fP is referred to as
$(R sub c , G sub c , B sub c , A sub c )$.
They are understood to have integer values between 0 and
$(k sub R , k sub G , k sub B , k sub A )$,
where
.P
.RS
.ce
$k sub c ~=~ 2 sup m sub c - 1$
.RE
.P
and
$(m sub R , m sub G , m sub B , m sub A )$
is the number of red,
green,
blue,
and alpha bitplanes.
.P
Source and destination scale factors are referred to as
$(s sub R , s sub G , s sub B , s sub A )$ and
$(d sub R , d sub G , d sub B , d sub A )$.
The scale factors described in the table,
denoted $(f sub R , f sub G , f sub B , f sub A )$,
represent either source or destination factors.
All scale factors have range [0,\ 1].
.P
.TS
center;
lb cb
l c .
_
Parameter $(f sub R , ~~ f sub G , ~~ f sub B , ~~ f sub A )$
_
\%\f3GL_ZERO\fP $(0, ~0, ~0, ~0 )$
\%\f3GL_ONE\fP $(1, ~1, ~1, ~1 )$
\%\f3GL_SRC_COLOR\fP $(R sub s / k sub R , ~G sub s / k sub G , ~B sub s / k sub B , ~A sub s / k sub A )$
\%\f3GL_ONE_MINUS_SRC_COLOR\fP $(1, ~1, ~1, ~1 ) ~-~ (R sub s / k sub R , ~G sub s / k sub G , ~B sub s / k sub B , ~A sub s / k sub A )$
\%\f3GL_DST_COLOR\fP $(R sub d / k sub R , ~G sub d / k sub G , ~B sub d / k sub B , ~A sub d / k sub A )$
\%\f3GL_ONE_MINUS_DST_COLOR\fP $(1, ~1, ~1, ~1 ) ~-~ (R sub d / k sub R , ~G sub d / k sub G , ~B sub d / k sub B , ~A sub d / k sub A )$
\%\f3GL_SRC_ALPHA\fP $(A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A )$
\%\f3GL_ONE_MINUS_SRC_ALPHA\fP $(1, ~1, ~1, ~1 ) ~-~ (A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A )$
\%\f3GL_DST_ALPHA\fP $(A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A )$
\%\f3GL_ONE_MINUS_DST_ALPHA\fP $(1, ~1, ~1, ~1 ) ~-~ (A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A )$
\%\f3GL_SRC_ALPHA_SATURATE\fP $(i, ~i, ~i, ~1 )$
\%\f3GL_CONSTANT_COLOR\fP $(R sub c, G sub c, B sub c, A sub c)$
\%\f3GL_ONE_MINUS_CONSTANT_COLOR\fP $(1, ~1, ~1, ~1 ) ~-~ (R sub c, G sub c, B sub c, A sub c)$
\%\f3GL_CONSTANT_ALPHA\fP $(A sub c, A sub c, A sub c, A sub c)$
\%\f3GL_ONE_MINUS_CONSTANT_ALPHA\fP $(1, ~1, ~1, ~1 ) ~-~ (A sub c, A sub c, A sub c, A sub c)$
_
.TE
.sp
In the table,
.P
.RS
.nf
.IP
$i ~=~ min (A sub s , ~k sub A ~-~ A sub d ) ~/~ k sub A$
.fi
.RE
.P
To determine the blended RGBA values of a pixel when drawing in RGBA mode,
the system uses the following equations:
.P
.RS
.nf
.IP
$R sub d ~=~ mark min ( k sub R, ~R sub s~s sub R~+~R sub d~d sub R )$
$G sub d ~=~ lineup min ( k sub G, ~G sub s~s sub G~+~G sub d~d sub G )$
$B sub d ~=~ lineup min ( k sub B, ~B sub s~s sub B~+~B sub d~d sub B )$
$A sub d ~=~ lineup min ( k sub A, ~A sub s~s sub A~+~A sub d~d sub A )$
.fi
.RE
.P
Despite the apparent precision of the above equations,
blending arithmetic is not exactly specified,
because blending operates with imprecise integer color values.
However,
a blend factor that should be equal to 1
is guaranteed not to modify its multiplicand,
and a blend factor equal to 0 reduces its multiplicand to 0.
For example,
when \f2sfactor\fP is \%\f3GL_SRC_ALPHA\fP,
\f2dfactor\fP is \%\f3GL_ONE_MINUS_SRC_ALPHA\fP,
and $A sub s$ is equal to $k sub A$,
the equations reduce to simple replacement:
.P
.RS
.nf
.IP
$R sub d ~=~ mark R sub s$
$G sub d ~=~ lineup G sub s$
$B sub d ~=~ lineup B sub s$
$A sub d ~=~ lineup A sub s$
.fi
.RE
.P
.SH EXAMPLES
.P
Transparency is best implemented using blend function
(\%\f3GL_SRC_ALPHA\fP, \%\f3GL_ONE_MINUS_SRC_ALPHA\fP)
with primitives sorted from farthest to nearest.
Note that this transparency calculation does not require
the presence of alpha bitplanes in the frame buffer.
.P
Blend function
(\%\f3GL_SRC_ALPHA\fP, \%\f3GL_ONE_MINUS_SRC_ALPHA\fP)
is also useful for rendering antialiased points and lines
in arbitrary order.
.P
Polygon antialiasing is optimized using blend function
.br
(\%\f3GL_SRC_ALPHA_SATURATE\fP, \%\f3GL_ONE\fP)
with polygons sorted from nearest to farthest.
(See the \%\f3glEnable\fP, \%\f3glDisable\fP reference page and the
\%\f3GL_POLYGON_SMOOTH\fP argument for information on polygon antialiasing.)
Destination alpha bitplanes,
which must be present for this blend function to operate correctly,
store the accumulated coverage.
.SH NOTES
Incoming (source) alpha is correctly thought of as a material opacity,
ranging from 1.0 ($K sub A$), representing complete opacity,
to 0.0 (0), representing complete
transparency.
.P
When more than one color buffer is enabled for drawing,
the GL performs blending separately for each enabled buffer,
using the contents of that buffer for destination color.
(See \%\f3glDrawBuffer\fP.)
.P
Blending affects only RGBA rendering.
It is ignored by color index renderers.
.P
\%\f3GL_CONSTANT_COLOR\fP, \%\f3GL_ONE_MINUS_CONSTANT_COLOR\fP,
\%\f3GL_CONSTANT_ALPHA\fP, \%\f3GL_ONE_MINUS_CONSTANT_ALPHA\fP are only
available if the \%\f3GL_ARB_imaging\fP is supported by your implementation.
.SH ERRORS
\%\f3GL_INVALID_ENUM\fP is generated if either \f2sfactor\fP or \f2dfactor\fP is not an
accepted value.
.P
\%\f3GL_INVALID_OPERATION\fP is generated if \%\f3glBlendFunc\fP
is executed between the execution of \%\f3glBegin\fP
and the corresponding execution of \%\f3glEnd\fP.
.SH ASSOCIATED GETS
\%\f3glGet\fP with argument \%\f3GL_BLEND_SRC\fP
.br
\%\f3glGet\fP with argument \%\f3GL_BLEND_DST\fP
.br
\%\f3glIsEnabled\fP with argument \%\f3GL_BLEND\fP
.br
.SH SEE ALSO
\%\f3glAlphaFunc(3G)\fP,
\%\f3glBlendColor(3G)\fP,
\%\f3glBlendEquation(3G)\fP,
\%\f3glClear(3G)\fP,
\%\f3glDrawBuffer(3G)\fP,
\%\f3glEnable(3G)\fP,
\%\f3glLogicOp(3G)\fP,
\%\f3glStencilFunc(3G)\fP
|