Light | Dark

# docs.GL

GLSL 4
GLSL ES 3

# bitfieldInsert

## Name

bitfieldInsert — insert a range of bits into an integer

## Declaration

`genIType bitfieldInsert(` | genIType base,
| genIType insert,
| int offset,
| int bits`)`;

`genUType bitfieldInsert(` | genUType base,
| genUType insert,
| int offset,
| int bits`)`;

## Parameters

`base`

  Specifies the integer into which to insert `insert`.

`insert`

  Specifies the the value of the bits to insert.

`offset`

  Specifies the index of the first bit to insert.

`bits`

  Specifies the number of bits to insert.

## Description

`bitfieldInsert` inserts the `bits` least significant bits of `insert` into `base` at offset `offset`. The returned value will have bits [`offset`, `offset` + `bits` + 1] taken from [0, `bits` - 1] of `insert` and all other bits taken directly from the corresponding bits of `base`. If `bits` is zero, the result will simply be the original value of `base`. The result will be undefined if `offset` or `bits` is negative, or if the sum of `offset` and `bits` is greater than the number of bits used to store the operand.

## Version Support

| OpenGL ES Shading Language Version
--- | ---
Function Name | 1.00 | 3.00 | 3.10
`bitfieldInsert` | - | - | ✔

## See Also

bitfieldExtract

## 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. https://opencontent.org/openpub/.

Think you can improve this page? Edit this page on GitHub.