GLBLENDEQUATION(3G)
π GLBLENDEQUATION(3G) β the blend-equation glow-up
okay so real talk, this is the GLBLENDEQUATION(3G) page from the [FIXME: manual] set, and it's lowkey the blueprint for how your pixels blend together. bestie, it's giving "how do two colors become one color" and honestly? iconic. π
β¨ NAME β¨
glBlendEquation β specify the equation used for both the RGB blend equation and the Alpha blend equation π
πΈ C SPECIFICATION πΈ
void glBlendEquation(GLenum mode);
void glBlendEquationi(GLuint buf, GLenum mode);
two functions, one mission: telling OpenGL how to do the math. no cap, that's the whole vibe. β¨
π¦ PARAMETERS π¦
bufβ forglBlendEquationi, this specifies the index of the draw buffer for which to set the blend equation. like, which buffer are we doing a makeover on bestie? πmodeβ specifies how source and destination colors are combined. it must be one of these, periodt:GL_FUNC_ADDGL_FUNC_SUBTRACTGL_FUNC_REVERSE_SUBTRACTGL_MINGL_MAX
that's the whole list, don't try to freestyle with anything else π
π DESCRIPTION π
okay so the blend equations are literally the rules for how a new pixel (the ''source'' color β the main character π) gets combined with a pixel that's already chillin' in the framebuffer (the ''destination'' color β the supporting role π«Ά).
this function sets both the RGB blend equation and the alpha blend equation to a single equation. one call, two glow-ups. efficiency queen. π
glBlendEquationi specifies the blend equation for a single draw buffer, whereas glBlendEquation sets the blend equation for all draw buffers. so if you're only feeling one buffer today, use the i version; if the whole squad needs the same treatment, go with the plain one. π
these equations are only half the story β they use the source and destination blend factors specified by eitherglBlendFunc()orglBlendFuncSeparate(). π
def go check glBlendFunc() or glBlendFuncSeparate() for a description of the various blend factors, because that's where the actual factor lore lives. consider it required reading, bestie. ππ
Okay so before we get into the actual equations, let's establish who's who, because the notation is doing a lot π«Ά
In the equations that follow, the source and destination color components are called R s G s B s A s and R d G d B d A d, respectively. The result color is called R r G r B r A r. The source and destination blend factors are written s R s G s B s A and d R d G d B d A, respectively. And for all of these equations, every color component is understood to have a value in the range 0 to 1 β¨ (no rogue 255s here, bestie, we're normalized).
π the big table, lovingly transcribed
Each mode gives you an RGB Components column and an Alpha Component column. Let's go π
GL_FUNC_ADD
RGB components:
Rr = Rs sR + Rd dR
Gr = Gs sG + Gd dG
Br = Bs sB + Bd dB
Alpha component:
Ar = As sA + Ad dA
Literally the classic: source times source factor, plus dest times dest factor. Iconic, no notes πΈ
GL_FUNC_SUBTRACT
RGB components:
Rr =
Alpha component:
Ar =
π and that's exactly where this part runs out β the subtraction side picks up in the next chunk, don't come for me, the manpage itself splits here π
okay so picking up exactly where the table left off β and ngl, bestie, this thing is sculptural π the formatter rotated every cell so the whole grid is reading sideways. Tilt your head ninety degrees and it's actually gorgeous. Here's the raw thing, character for character, so nothing gets lost in translation π
β β 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 β
okay let's decode this masterpiece together, because it is readable, it's just doing yoga π§ββοΈ
- The two big columns at the top are headed
RandAβ red on the left, alpha on the right. Two channels, two columns, both fully committed to the sideways lifestyle π - Down the
Rcolumn you've got the letters spelling out the red-and-alpha maths:R,s, then that sneaky little invisible-times characterβ’, thens,Rβ i.e. source-red and dest-red hanging out together β then the-minus sign, thenR,d,β’,d,R. Same exact shape of thing in theAcolumn, just withAinstead ofR, so whatever formula you read on the red side has its alpha twin right next to it. Twin flames fr π«Ά - Then
Grand=show up, and the whole pattern restarts withGwhereRwas:G,s,β’,s,G,-,G,d,β’,d,G. That's the green channel clocking in π - Then
Brand=β same deal,Ball the way down,B,s,β’,s,B,-,B,d,β’,d,B. Blue's turn π - The
-shows up in every single one of those runs, sitting right between the "source" letters and the "dest" letters β that's the whole point of the function this table belongs to, iykyk π - Then there's a fat horizontal rule β
βββββΌββββΌββββ€β which is the table drawing a line under everything above it, iconic behaviour π - Under that line, the left column finally says the quiet part out loud:
GL_FUNC_REVERSE_SUBTRACT. That's the row header, bestie, the main character whose data all of the above actually is β¨ - And its
Rcell opens withRrand an=, then does the same dance:R,d,β’,d,R, then-, thenR,s,β’,s,R. Meanwhile theAcell is the exact mirror:Ar,=,A,d,β’,d,A,-,A,s,β’,s,A.
so yeah β everything in that A column is the alpha-channel copy of whatever the R column is doing, and the row is the plain GL_FUNC_REVERSE_SUBTRACT behaviour. No cap, once you see the pattern it's giving "spreadsheet but make it a vibe" π
lowkey important π¨ β the cells above got rotated by the formatter, so if you're copying this anywhere, don't copy the layout, copy the meaning. The letters, the-, the=, theGrandBrmarkers and theR/Acolumn headers are the actual content. The box-drawing characters are just decoration doing its little dance π
and there's more coming, so don't go anywhere bestie β we're not done yet π
okay bestie we're literally mid-table, no ceremony, no intro, just vibes and box-drawing characters π here's the chunk exactly as it renders:
β β 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 what are we even looking at, bestie? it's giving equation table energy β¨ the left column is where the equation name lives (and in this chunk the only label that survived is GL_MIN β the row above it got its name cut off back in the previous part, so don't come for me, that's just where the page broke π).
the middle column is where the math for R / G / B lives, and the right column is the A one. reading down the GL_MIN row you literally get:
Rr=minβ¦ withRsandRdstacked under it π«ΆAr=minβ¦ withAsandAdstacked under it π«Ά
like the column is so narrow that the whole thing got laid out vertically, which is honestly icon behavior π
the row above it is the same deal β Gr = and Br = with the G and B terms (and a lil minus sign - doing its thing in there) all stacked. notice its right-hand cell is straight-up empty in this render, no cap.
also a heads up: some of those cells have invisible characters in them, so if a line looks blank or a glyph looks like nothing, it's not your terminal gaslighting you β that's just the table π
and then it justβ¦ stops at another Gr = min because plot twist, there's more of this table waiting in the next part π don't close the tab, we're so close πΈ
okay so the table keeps going and the back half is where it gets kind of unhinged-looking in raw form π β it's literally just a big grid where the characters are positioned weird, so let me translate the whole thing for you, no cap π
The middle and right cells are spelling out, channel by channel, what each blend equation computes from the source components (s) and destination components (d) β and the result component is the r one, obviously, iykyk β¨
GL_MINβ lowkey the chill one: it just takes whichever value is smaller, per component πRr = min(Rs, Rd)Gr = min(Gs, Gd)Br = min(Bs, Bd)Ar = min(As, Ad)
GL_MAXβ the main character version: takes whichever value is bigger, per component π₯Rr = max(Rs, Rd)Gr = max(Gs, Gd)Br = max(Bs, Bd)Ar = max(As, Ad)
So like, if you clock the raw grid and see Br chilling near min and Bs/Bd stacked vertically under it? That's the blue channel of GL_MIN, just written in a cell so tall it needs its own zip code π«Ά Same energy for Gr/Gs/Gd right above it, and the Rr/Rs/Rd and Ar/As/Ad stack over in the GL_MAX row with max instead of min β one little substitution and the whole vibe flips π¦
bestie please don't try to read the ASCII art column-by-column on a narrow terminal, it will simply not render and you'll be sad π the equations are the whole point, the box-drawing characters are just decoration π
Every single min and max in that grid is doing exactly one job: compare the source component against the destination component for that channel, pick the winner, and drop it into the corresponding result component. The red, green, blue and alpha channels each get their own comparison, and none of them peek at what the other channels decided β they're all little independent icons doing their own thing π
and once you've internalized that, the rest of this table is gonna read like a text from your bestie, fr fr πΈ
(the big table from the last part wraps up right here β same = and max columns, same B, Bs, Bd down the side π
β¦and clause time, bestie:)
The results of these equations are clamped to the range 0 1.
The GL_MIN and GL_MAX equations are literally made for apps that analyze image data β image thresholding against a constant color, for example, that's their whole moment. And GL_FUNC_ADD? That one's the main character for antialiasing and transparency, among other things. π
Initially, both the RGB blend equation and the alpha blend equation are set to GL_FUNC_ADD. Like, out of the box, no setup needed, she's already add-ing. β¨
π¦ NOTES π¦
So GL_MIN and GL_MAX do not use the source or destination factors β like, at all. They only look at the source and destination colors. Factors stay in their lane. π
π ERRORS π
GL_INVALID_ENUMgets generated ifmodeis not one ofGL_FUNC_ADD,GL_FUNC_SUBTRACT,GL_FUNC_REVERSE_SUBTRACT,GL_MAX, orGL_MIN. Wrong mode = instant vibe check failure, sorry.GL_INVALID_VALUEgets generated byglBlendEquationiifbufis greater than or equal to the value ofGL_MAX_DRAW_BUFFERS. You cannot simply invent a draw buffer index, bestie. π
π ASSOCIATED GETS π
glGet()with an argument ofGL_BLEND_EQUATION_RGBglGet()with an argument ofGL_BLEND_EQUATION_ALPHA
(peek at what she's set to, iykyk πΈ)
π VERSION SUPPORT π
The original table's columns are Function / Feature Name on the left and OpenGL Version across the top, running 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5. Here's the tea, row by row:
glBlendEquationβ β in2.0, β in2.1, β in3.0, β in3.1, β in3.2, β in3.3, β in4.0, β in4.1, β in4.2, β in4.3, β in4.4, β in4.5. A complete sweep, no notes, iconic behavior. πglBlendEquationiβ-in2.0,-in2.1,-in3.0,-in3.1,-in3.2,-in3.3, then β in4.0, β in4.1, β in4.2, β in4.3, β in4.4, β in4.5. She arrived late to the party (4.0 girlie) but she showed up and she ate. π
π«Ά SEE ALSO π«Ά
glBlendColor()glBlendFunc()glBlendFuncSeparate()
(yes, the original really has no comma between the last two β we don't fix, we just notice π)
π COPYRIGHT π
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group
okay that's the whole page, you made it to the end, I'm so proud of you fr fr π§β¨ one last little footer moment: the source still says [FIXME: source] (yes, the manpage itself has a to-do, relatable π), it's dated 08/09/2021, and it's filed under GLBLENDEQUATION(3G). go blend something, bestie β you've got this π
π¦ 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