Specifies how the red, green, blue, and alpha source blending factors are computed. The initial value is GL_ONE.
Specifies how the red, green, blue, and alpha destination blending factors are computed. The following symbolic constants are accepted: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA. GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA. The initial value is GL_ZERO.
Generated using TypeDoc
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 glEnable and glDisable with argument GL_BLEND to enable and disable blending.
glBlendFunc
defines the operation of blending when it is enabled. sfactor specifies which method is used to scale the source color components. dfactor specifies which method is used to scale the destination color components. Both parameters must be one of the following symbolic constants: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE, GL_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR, GL_SRC1_ALPHA, and GL_ONE_MINUS_SRC1_ALPHA. The possible methods are described in the following table. Each method defines four scale factors, one each for red, green, blue, and alpha. In the table and in subsequent equations, first source, second source and destination color components are referred to as (๐s0,๐s0,๐s0,๐s0), (๐s1,๐s1,๐s1,๐s1) and (๐d,๐d,๐d,๐d), respectively. The color specified by glBlendColor is referred to as (๐c,๐c,๐c,๐c). They are understood to have integer values between 0 and (k๐,k๐,k๐,k๐), where๐๐ = 2แตแถ โ 1
and (๐ฆ๐ , ๐ฆ๐บ, ๐ฆ๐ต, ๐ฆ๐ด) is the number of red, green, blue, and alpha bitplanes.
Source and destination scale factors are referred to as (๐ ๐,๐ ๐,๐ ๐,๐ ๐) and (d๐,d๐,d๐,d๐). The scale factors described in the table, denoted (f๐,f๐,f๐,f๐), represent either source or destination factors. All scale factors have range [0,1].
In the table,
๐ข = min(๐๐ , ๐๐ โ ๐d) / ๐๐
To determine the blended RGBA values of a pixel, the system uses the following equations:
๐๐ = min(๐๐ , ๐โs๐ + ๐๐d๐ ) ๐d = min(๐๐บ, ๐โs๐บ + ๐๐d๐บ) ๐๐ = min(๐๐ต, ๐โs๐ต + ๐๐d๐ต) ๐d = min(๐๐ด, ๐โs๐ด + ๐๐d๐ด)
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 sfactor is GL_SRC_ALPHA, dfactor is GL_ONE_MINUS_SRC_ALPHA, and ๐โ is equal to ๐๐ด, the equations reduce to simple replacement:
๐๐ = ๐โ ๐d = ๐โ ๐๐ = ๐โ ๐d = ๐โ