CLAMP(3G)
π CLAMP(3G) π
okay so bestie, welcome to clamp from the 3G manual section β yeah the OpenGL shading language girlies β¨ she's literally the "keep it in range" function and she ATE π
π NAME π
clamp β constrain a value so it lies between two further values π«Ά like a little velvet rope for your numbers
β¨ DECLARATION β¨
here's the whole friend group, no cap, all of them:
genType clamp(genType x, genType minVal, genType maxVal);
genType clamp(genType x, float minVal, float maxVal);
genDType clamp(genDType x, genDType minVal, genDType maxVal);
genDType clamp(genDType x, double minVal, double maxVal);
genIType clamp(genIType x, genIType minVal, genIType maxVal);
genIType clamp(genIType x, int minVal, int maxVal);
genUType clamp(genUType x, genUType minVal, genUType maxVal);
genUType clamp(genUType x, uint minVal, uint maxVal);
πΈ PARAMETERS πΈ
xβ the value you wanna constrain. the main character of this whole operation πminValβ the lower end of the range you're crammingxinto. the floor, the basement, the "no lower than this" π§maxValβ the upper end of that same range. the ceiling bestie, the "no higher than this" β
π DESCRIPTION π
so clamp hands you back the value of x, except it's been constrained to the range from minVal to maxVal. like, she will not let it out of the enclosure, periodt.
the returned value is computed as:
min()(max()(x, minVal), maxVal)
that's literally it. that's the whole vibe. the way that she's just min and max stacked on top of each otherβ¦ iconic π
π VERSION SUPPORT π
ikykw, GLSL versions got receipts. here's who showed up when:
clamp(genType) β β in1.10, β in1.20, β in1.30, β in1.40, β in1.50, β in3.30, β in4.00, β in4.10, β in4.20, β in4.30, β in4.40, β in4.50β she was there from DAY ONE, a founding member fr fr πclamp(genIType) β-in1.10,-in1.20, then β in1.30, β in1.40, β in1.50, β in3.30, β in4.00, β in4.10, β in4.20, β in4.30, β in4.40, β in4.50β late bloomer, joined at1.30πΈclamp(genUType) β-in1.10,-in1.20, then β in1.30, β in1.40, β in1.50, β in3.30, β in4.00, β in4.10, β in4.20, β in4.30, β in4.40, β in4.50β same exact glow-up timeline as her int sister π¦clamp(genDType) β-in1.10,-in1.20,-in1.30,-in1.40,-in1.50,-in3.30, then β in4.00, β in4.10, β in4.20, β in4.30, β in4.40, β in4.50β the double-precision diva arrived fashionably late at4.00and honestly? worth the wait π
bestie this is a table that got turned into a list, so read it like a table, not like a timeline of my feelings (it's both tho)
π₯ SEE ALSO π₯
min(), max() β her two besties, the ones she's literally built out of π«Ά
π COPYRIGHT π
Copyright Β© 2011-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 (again, yeah, there's two) π
Copyright Β© 2011-2014 Khronos Group
okay that's the whole page bestie, mwah ππ this one came from [FIXME: source] and it's dated 01/03/2018, and it lives under the name CLAMP(3G) β go forth and constrain your values, no cap πβ¨π
π¦ where this page comes from
- ubuntu jammy: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- ubuntu noble: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms