|
|
(4 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| {{infobox feature
| | #REDIRECT [[GLAPI/glBlendEquationSeparate]] |
| | name = glBlendEquation
| |
| | core = 1.0
| |
| }}
| |
| | |
| '''glBlendEquation:''' specify the equation used for both the RGB blend equation and the Alpha blend equation
| |
| | |
| == Function Definition ==
| |
| | |
| void '''glBlendEquation'''(GLenum ''mode'');
| |
| void '''glBlendEquationi'''(GLuint ''buf'', GLenum ''mode'');
| |
| | |
| ; buf
| |
| : for '''glBlendEquationi''', specifies the index of the draw buffer for which to set the blend equation.
| |
| ; mode
| |
| : specifies how source and destination colors are combined. It must be {{code|GL_FUNC_ADD}}, {{code|GL_FUNC_SUBTRACT}}, {{code|GL_FUNC_REVERSE_SUBTRACT}}, {{code|GL_MIN}}, {{code|GL_MAX}}.
| |
| | |
| == Description ==
| |
| | |
| The blend equations determine how a new pixel (the ''source'' color) is combined with a pixel already in the framebuffer (the ''destination'' color). This function sets both the RGB blend equation and the alpha blend equation to a single equation. '''glBlendEquationi''' specifies the blend equation for a single draw buffer whereas '''glBlendEquation''' sets the blend equation for all draw buffers.
| |
| | |
| These equations use the source and destination blend factors specified by either [[GLAPI/glBlendFunc|glBlendFunc]] or [[GLAPI/glBlendFuncSeparate|glBlendFuncSeparate]]. See [[GLAPI/glBlendFunc|glBlendFunc]] or [[GLAPI/glBlendFuncSeparate|glBlendFuncSeparate]] for a description of the various blend factors.
| |
| | |
| In the equations that follow, source and destination color components are referred to as <math>(R_s, G_s, B_s, A_s)</math> and <math>(R_d, G_d, B_d, A_d)</math>, respectively. The result color is referred to as <math>(R_r, G_r, B_r, A_r)</math>. The source and destination blend factors are denoted <math>(s_R, s_G, s_B, s_A)</math> and <math>(d_R, d_G, d_B, d_A)</math>, respectively. For these equations all color components are understood to have values in the range [0, 1].
| |
| | |
| {| class="wikitable" style="background-color:transparent;"
| |
| |+
| |
| ! '''Mode'''
| |
| ! '''RGB Components'''
| |
| ! '''Alpha Component'''
| |
| |+
| |
| | {{code|GL_FUNC_ADD}}
| |
| | <math>\begin{align}R_r & = s_R R_s + d_R R_d\\G_r & = s_G G_s + d_G G_d\\B_r & = s_B B_s + d_B B_d\end{align}</math>
| |
| | <math>A_r = s_A A_s + d_A A_d</math>
| |
| |+
| |
| | {{code|GL_FUNC_SUBTRACT}}
| |
| | <math>\begin{align}R_r & = s_R R_s - d_R R_d\\G_r & = s_G G_s - d_G G_d\\B_r & = s_B B_s - d_B B_d\end{align}</math>
| |
| | <math>A_r = s_A A_s - d_A A_d</math>
| |
| |+
| |
| | {{code|GL_FUNC_REVERSE_SUBTRACT}}
| |
| | <math>\begin{align}R_r & = d_R R_d - s_R R_s\\G_r & = d_G G_d - s_G G_s\\B_r & = d_B B_d - s_B B_s\end{align}</math>
| |
| | <math>A_r = d_A A_d - s_A A_s</math>
| |
| |+
| |
| | {{code|GL_MIN}}
| |
| | <math>\begin{align}R_r & = min(R_s, R_d)\\G_r & = min(G_s, G_d)\\B_r & = min(B_s, B_d)\end{align}</math>
| |
| | <math>A_r = min(A_s, A_d)</math>
| |
| |+
| |
| | {{code|GL_MAX}}
| |
| | <math>\begin{align}R_r & = max(R_s, R_d)\\G_r & = max(G_s, G_d)\\B_r & = max(B_s, B_d)\end{align}</math>
| |
| | <math>A_r = max(A_s, A_d)</math>
| |
| |}
| |
| | |
| The results of these equations are clamped to the range [0, 1].
| |
| | |
| The {{code|GL_MIN}} and {{code|GL_MAX}} equations are useful for applications that analyze image data (image thresholding against a constant color, for example). The {{code|GL_FUNC_ADD}} equation is useful for antialiasing and transparency, among other things.
| |
| | |
| Initially, both the RGB blend equation and the alpha blend equation are set to {{code|GL_FUNC_ADD}}.
| |
| | |
| == Notes ==
| |
| | |
| The {{code|GL_MIN}}, and {{code|GL_MAX}} equations do not use the source or destination factors, only the source and destination colors.
| |
| | |
| == Errors ==
| |
| | |
| {{code|GL_INVALID_ENUM}} is generated if ''mode'' is not one of {{code|GL_FUNC_ADD}}, {{code|GL_FUNC_SUBTRACT}}, {{code|GL_FUNC_REVERSE_SUBTRACT}}, {{code|GL_MAX}}, or {{code|GL_MIN}}.
| |
| | |
| {{code|GL_INVALID_VALUE}} is generated by '''glBlendEquationi''' if ''buf'' is greater than or equal to the value of {{code|GL_MAX_DRAW_BUFFERS}}.
| |
| | |
| == Associated Gets ==
| |
| | |
| [[GLAPI/glGet|glGet]] with an argument of {{code|GL_BLEND_EQUATION_RGB}}
| |
| | |
| [[GLAPI/glGet|glGet]] with an argument of {{code|GL_BLEND_EQUATION_ALPHA}}
| |
| | |
| == See Also ==
| |
| | |
| [[GLAPI/glBlendColor|glBlendColor]], [[GLAPI/glBlendFunc|glBlendFunc]], [[GLAPI/glBlendFuncSeparate|glBlendFuncSeparate]]
| |
| | |
| == Copyright ==
| |
| | |
| Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see [http://oss.sgi.com/projects/FreeB/ http://oss.sgi.com/projects/FreeB/].
| |
|
| |
|
| [[Category:Core API Ref Post Fragment Shader Operations|BlendEquation]] | | [[Category:Core API Ref Post Fragment Shader Operations|BlendEquation]] |
| [[Category:Core API Reference|BlendEquation]] | | [[Category:Core API Reference|BlendEquation]] |