BITFIELDEXTRACT(3G)
π BITFIELDEXTRACT(3G) π
okay bestie, you've landed on BITFIELDEXTRACT(3G) π this whole page is about one lil function called bitfieldExtract, and her entire personality is "gimme an integer, I'll hand you back a slice of its bits." no cap. let's get into it π¦
β¨ NAME β¨
bitfieldExtract β extract a range of bits from an integer π
π DECLARATION π
genIType bitfieldExtract(genIType value, int offset, int bits);
genUType bitfieldExtract(genUType value, int offset, int bits);
two flavours, same energy. pick the one that matches your type, she's not picky π
πΈ PARAMETERS πΈ
valueβ the integer you're pulling bits out of. your source material, your main character πoffsetβ the index of the first bit to extract. where the slice starts, fr fr.bitsβ how many bits you want. the size of your little scoop π¨
π₯ DESCRIPTION π₯
okay so bitfieldExtract takes a subset of the bits of value and returns them in the least significant bits of the result. it's giving "cut a strip out and slide it down to the front."
the range of bits extracted is [offset, offset + bits + 1].
for unsigned data types, the most significant bits of the result will be set to zero. clean. pristine. zeroes. β¨
for signed data types, the most significant bits will be set to the value of bit offset + base - 1 (i.e., it is sign extended to the width of the return type). so she copies the sign bit all the way up, iconic behaviour.
if bits is zero, the result will be zero. periodt. nothing in, nothing out π«₯
π¨ the result will be undefined ifoffsetorbitsis negative, or if the sum ofoffsetandbitsis greater than the number of bits used to store the operand. bestie. do NOT do this. that's not a vibe check, that's a vibe crash. π
π VERSION SUPPORT π
so here's the tea on which OpenGL Shading Language versions ship her. the row is labelled bitfieldInsert in the original (yes, we're all just gonna look at that and move on π), and the columns run 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50:
1.10β-(not here, girl)1.20β-1.30β-1.40β-1.50β-3.30β-4.00β β4.10β β4.20β β4.30β β4.40β β4.50β β
so she showed up in 4.00 and never left. consistent queen π
π SEE ALSO π
bitfieldExtract()
(yeah. she's linking herself. self-love is the moment. slay π )
π 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 Β© 2011-2014 Khronos Group
okay that's the whole page bestie π«Ά source says [FIXME: source], the date on this one is 01/03/2018, and it's filed under BITFIELDEXTRACT(3G). go extract some bits, you absolute legend ππ
π¦ 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