GLBLENDEQUATIONSEPAR(3G)
π GLBLENDEQUATIONSEPAR(3G) π
okay bestie, welcome to the glBlendEquationSeparate manual page from section 3G β it's giving βblend math, but split the RGB and alpha vibesβ π
β¨
πΈ NAME πΈ
glBlendEquationSeparate β set the RGB blend equation and the alpha blend equation separately, because sometimes one equation for everything is simply not the main character energy we deserve π«Ά
β¨ C SPECIFICATION β¨
here's the exact signature tea, character for character, no edits, fr fr:
void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
void glBlendEquationSeparatei(GLuint buf, GLenum modeRGB,
GLenum modeAlpha);
π PARAMETERS π
bufβ forglBlendEquationSeparatei, this specifies the index of the draw buffer for which you're setting the blend equations. lowkey the βwhich buffer?β parameter πmodeRGBβ specifies the RGB blend equation, aka how the red, green, and blue components of the source and destination colors get combined. it must beGL_FUNC_ADD,GL_FUNC_SUBTRACT,GL_FUNC_REVERSE_SUBTRACT,GL_MIN, orGL_MAX. those are the only legal values, periodt πmodeAlphaβ specifies the alpha blend equation, aka how the alpha component of the source and destination colors gets combined. it must also beGL_FUNC_ADD,GL_FUNC_SUBTRACT,GL_FUNC_REVERSE_SUBTRACT,GL_MIN, orGL_MAX. same list, alpha edition π
π¦ DESCRIPTION π¦
blend equations are the rulebook for how a new pixel β the source color β gets combined with a pixel that's already chillin' in the framebuffer β the destination color. these functions are the βsplit the equationβ girlies: they specify one blend equation for the RGB-color components and one blend equation for the alpha component. iconic, honestly β¨
glBlendEquationSeparatei specifies the blend equations for a single draw buffer, whereas glBlendEquationSeparate sets the blend equations for all draw buffers. that's the whole difference β one buffer vs. every buffer, no cap π«Ά
the blend equations use the source and destination blend factors specified by either glBlendFunc() or glBlendFuncSeparate(). if you want the full description of the various blend factors, go peek at glBlendFunc() or glBlendFuncSeparate() β that's where the blend-factor lore lives, iykyk π
okay so before we even look at the equations, here's the naming sitch β please do not scroll past this, it's lowkey the entire cheat sheet and you WILL be lost without it:
- the source color components are referred to as
R s G s B s A sπ«Ά - the destination color components are referred to as
R d G d B d A d - the result color is referred to as
R r G r B r A r - the source blend factors are denoted
s R s G s B s A⨠- the destination blend factors are denoted
d R d G d B d A
(and yeah, if you're reading the plain-text version and the little letters look like they fell down the stairs β that's just the subscripts rendering vertically. R with a s chilling underneath it. you got this π
)
for all of these equations, every single color component is understood to have values in the range 0 1. normalized. no 0β255 chaos here, she's classy. periodt.
GL_FUNC_ADD π₯
RGB Components β iconic, the default, the moment:
Rr = Rs sR + Rd dR
Gr = Gs sG + Gd dG
Br = Bs sB + Bd dB
Alpha Component:
Ar = As sA + Ad dA
literally just source-times-its-factor plus destination-times-its-factor, for each and every component. she ate and left no crumbs π
GL_FUNC_SUBTRACT πΈ
RGB Components β okay so this one starts like:
Rr =
Alpha Component:
Ar =
...and now we hit the part where the actual table shows up β and bestie, it's coming at you sideways π
. Rotate your head ninety degrees (or just tilt your whole laptop, no judgment here) and each lane spells out, channel by channel, what every blend equation is doing. R, G and B each get their own lil' lane inside the RGB column, and alpha has its own lane over on the right.
β β R β A β
β β s β s β
β β β β
β β β’ β β’ β
β β s β s β
β β R β A β
β β β β
β β - β - β
β β R β A β
β β d β d β
β β β β
β β β’ β β’ β
β β d β d β
β β R β A β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β Gr β β
β β = β β
β β β β
β β G β β
β β s β β
β β β β
β β β’ β β
β β s β β
β β G β β
β β β β
β β - β β
β β G β β
β β d β β
β β β β
β β β’ β β
β β d β β
β β G β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β Br β β
β β = β β
β β β β
β β B β β
β β s β β
β β β β
β β β’ β β
β β s β β
β β B β β
β β β β
β β - β β
β β B β β
β β d β β
β β β β
β β β’ β β
β β d β β
β β B β β
ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β GL_FUNC_REVERSE_SUBTRACT β Rr β Ar β
β β = β = β
β β β β
β β R β A β
β β d β d β
β β β β
β β β’ β β’ β
β β d β d β
β β R β A β
β β β β
β β - β - β
β β R β A β
β β s β s β
β β β β
β β β’ β β’ β
β β s β s β
So like, how do you even read this thing? Here's the vibe check π«Ά:
- The
βbars are just the column walls, and thatβββββΌββββ€line is the divider where one table row ends and the next one starts. Basic table anatomy, nothing shady. - Every lane is one channel writing its own little formula top-to-bottom. The RGB side has separate lanes for
Rr,GrandBr; the alpha side has one lane,Ar. All thesterms anddterms you see are the pieces each lane is built out of. - The chunk up top is mid-thought β the head of that lane is up in the part we already read, so what you're catching is the tail end of it: the
Rsβ¦-β¦Rdbit, then theGr =β¦Gsβ¦-β¦Gdbit, then theBr =β¦Bsβ¦-β¦Bdbit, with the alpha column running its ownAsβ¦-β¦Adalongside. Same equation row, four channels, zero chaos π. - Some of those lines look empty but there's genuinely an invisible character sitting in them (yes,
β’, it's there, ngl it's giving ghost π») β don't let a "blank" line gaslight you into thinking the lane stops. - Then the divider hits and the next row introduces itself as
GL_FUNC_REVERSE_SUBTRACT, doingRr = Rd - Rson the RGB side andAr = Ad - Ason the alpha side. Notice the operands are in the opposite order from the subtract-y row above it β that flip is literally theREVERSEin the name, you can see it with your own eyeballs π. - And the bottom of this chunk cuts off mid-lane again, so hold that thought β the rest of the table is coming right up πΈ.
okay so we're still in the middle of this absolute β¨unitβ¨ of a table, and I am not about to paraphrase a hundred box-drawing characters at you β here's the rest of this chunk, copied over exactly, character for character, invisible subscript gremlins included π
β β R β A β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β Gr β β
β β = β β
β β β β
β β G β β
β β d β β
β β β β
β β β’ β β
β β d β β
β β G β β
β β β β
β β - β β
β β G β β
β β s β β
β β β β
β β β’ β β
β β s β β
β β G β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β Br β β
β β = β β
β β β β
β β B β β
β β d β β
β β β β
β β β’ β β
β β d β β
β β B β β
β β β β
β β - β β
β β B β β
β β s β β
β β β β
β β β’ β β
β β s β β
β β B β β
ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β GL_MIN β Rr β Ar β
β β = β = β
β β β β
β β min β min β
β β β‘ β β‘ β
β β β β
β β β β
β β R β A β
β β s β s β
β β β β
β β β β
β β R β A β
β β d β d β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β β β
β β Gr β β
β β = β β
β β β β
β β min β β
β β β‘ β β
β β β β
so like. what is this even giving π«Ά here's the tea: the rows are stacked vertically because the typesetting went full main-character and refused to fit a whole equation on one line. the bits with the tiny invisible characters are the subscripts doing their little dance β that's just how this page renders, nothing spicy hiding in there, promise πΈ
the β¨actually readableβ¨ row is the GL_MIN one at the bottom, because it spells things out plainly: the result red Rr is stuffed full of min, you get R, s, R, d stacked up meaning the source and destination reds go in, and same exact situation on the alpha side with Ar, A, s, A, d. then it starts the whole min bit over again for green with Gr = min and the fragment cuts off mid-thought π
and yes, the row above it is the tail end of whatever equation we were already in the middle of from the last part β R, Gr, =, G, `Go ahead and read those columns as "here's what happens to red" and "here's what happens to alpha", top to bottom.
the table is still going, bestie, we are not done β keep scrolling π
okay so we're picking up right in the middle of the big equation grid π β no heading needed, we're just sliding back into the same cell-by-cell layout like nothing happened π
The row that just wrapped up above us is finishing off its blue slot like this:
Br = min(Bs, Bd)β that's the blue result up top, theminfunction under it, and thenBsstacked overBdin the grid (subscriptson top, subscriptdunderneath, exactly how every other cell in this giant grid is laid out π«Ά)
And the far-right column for that same row is still showing its G header with Gs and Gd stacked beneath it β the grid is super wide and this page is cropped, so that's genuinely all we get of that column before the next row starts β¨
Then we hit a row that actually has a label pinned to the left, and it's GL_MAX π β main character row, honestly:
Middle column, the RGB side π:
Rr = max(Rs, Rd)β the red result ismaxwithRsandRdas its two inputsGr = max(Gs, Gd)β green gets the identical treatment,maxoverGsandGd- the
Brline for this row gets cut off at the bottom of the page π so it's waiting for you in the next chunk, not skipped, just cropped
Right column, the alpha side π:
Ar = max(As, Ad)β alpha result ismaxoverAsandAd
So the whole GL_MAX row is just max in every slot, no cap, no mixing it up β Rr, Gr and Ar each take the max of their two operands, and Br is queued up right below the fold π₯
ngl the grid looks chaotic at first glance but it's lowkey just one cell per channel β result on top, function in the middle, the two operands stacked underneath π¦
β β = β β
β β β β
β β max β β
β β β‘ β β
β β β β
β β β β
β β B β β
β β s β β
β β β β
β β β β
β β β β
β β B β β
β β d β β
ββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ
and that's the rest of the table, no crumbs left π
The results of these equations are clamped to the range 0 1. so like, nothing escapes the 0β1 bounds, bestie, the math gets contained β¨
πΈ NOTES πΈ
The GL_MIN, and GL_MAX equations do not use the source or destination factors, only the source and destination colors. iconic behaviour honestly β they straight up ignore the factors and vibe with the raw colors π
π ERRORS π
GL_INVALID_ENUMis generated if eithermodeRGBormodeAlphais not one ofGL_FUNC_ADD,GL_FUNC_SUBTRACT,GL_FUNC_REVERSE_SUBTRACT,GL_MAX, orGL_MIN. so pick from the list or the driver WILL yell at you, no cap πGL_INVALID_VALUEis generated byglBlendEquationSeparateiifbufis greater than or equal to the value ofGL_MAX_DRAW_BUFFERS. off-by-one girlies stay winning,>=is right there in the spec π
π«Ά ASSOCIATED GETS π«Ά
glGet()with an argument ofGL_BLEND_EQUATION_RGBglGet()with an argument ofGL_BLEND_EQUATION_ALPHA
that's how you check what you set, yw π
π VERSION SUPPORT π
Here's the vibe check across the OpenGL versions, bestie β
glBlendEquationSeparateβ β in2.0,2.1,3.0,3.1,3.2,3.3,4.0,4.1,4.2,4.3,4.4,4.5(she's been here since day one, main character energy fr fr π)glBlendEquationSeparateiβ-in2.0,2.1,3.0,3.1,3.2,3.3; β in4.0,4.1,4.2,4.3,4.4,4.5(late arrival but she ATE, she showed up in4.0and stayed π )
π¦ SEE ALSO π¦
glGetString(), glBlendColor(), glBlendFunc(), glBlendFuncSeparate()
go read those next, iykyk π
π COPYRIGHT π
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group
yes bestie it's listed twice, i don't make the rules, i just keep every detail π
okay that's the whole page, you're officially educated π stay slay, stay clamped to 0β1, and go blend something gorgeous. ππ§β¨
β from [FIXME: source], dated 08/09/2021, and yeah the page tag is still GLBLENDEQUATIONSEPAR(3G) π (the [FIXME: source] is literally in there, i'm not making it up π)
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms