GLBINDSAMPLERS(3G)

✨ GLBINDSAMPLERS ✨

okay so bestie, this is a page from the 3G manual β€” the OpenGL one. buckle up, it's actually not that deep, but it IS iconic πŸŽ€


πŸ’– NAME

glBindSamplers β€” bind one or more named sampler objects to a sequence of consecutive sampler units. yes, plural samplers, plural units, we're doing a whole batch at once, slay πŸ’…


🌸 C SPECIFICATION

void glBindSamplers(GLuint first, GLsizei count,
                    const GLuint *samplers);

that's the whole signature, no cap. drop it straight into your code 🫢


πŸŽ€ PARAMETERS

  • first β€” the first sampler unit you wanna bind something to. like, the starting point of the whole operation ✨
  • count β€” how many samplers we're binding. the size of the squad πŸ’…
  • samplers β€” the address of an array holding the names of sampler objects that already exist. these are existing ones, bestie β€” not vibes, actual names 🌸

πŸ¦‹ DESCRIPTION

glBindSamplers takes sampler names from an array of already-existing sampler objects and binds them to a bunch of consecutive sampler units. count is literally the number of sampler objects whose names live in the samplers array. so it reads that many names out of the array and binds them to the count consecutive sampler units starting from first. one big group-chat bind, fr fr πŸ’–

now here's the part where you pay attention πŸ‘€ if the name zero shows up in the samplers array, then any existing binding to that sampler unit gets reset. gone. ghosted. and any non-zero entry in samplers must be the name of an existing sampler object β€” no making up names, that's not the move. when a non-zero entry is there, that sampler object gets bound to the corresponding sampler unit. and if samplers is NULL, it's exactly as if you'd passed an appropriately sized array containing only zeros. same energy, zero effort πŸ“

and because the spec loves to be extra, glBindSamplers is equivalent to this pseudo code:

for (i = 0; i < count; i++) {
    if (samplers == NULL) {
        glBindSampler(first + i, 0);
    } else {
        glBindSampler(first + i, samplers[i]);
    }
}

like, it literally is a lil for-loop in a trench coat 😭

here's the important nuance tho β€” each entry in samplers gets checked individually, and if one's found to be invalid, the state for that sampler unit won't change and you get an error. BUT βœ‹ the state for the other sampler units referenced by the command still gets updated. so it's not all-or-nothing, it's very much "we move, but not for the bad one" πŸ’€


🌈 NOTES

glBindSamplers is available only if the GL version is 4.4 or higher. that's the vibe check β€” older GL need not apply πŸ™ˆ


πŸ’€ ERRORS

  • GL_INVALID_OPERATION is generated if first + count is greater than the number of sampler units supported by the implementation. so watch your math bestie πŸ”₯
  • GL_INVALID_OPERATION is generated if any value in samplers is not zero or the name of an existing sampler object. zero or legit, there is no third option ✨

πŸ‘‘ ASSOCIATED GETS

  • glGet() with argument GL_SAMPLER_BINDING

⭐ VERSION SUPPORT

the table said: glBindSamplers as a function/feature name, across the OpenGL versions 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5 β€” and here's the breakdown:

  • 2.0 β€” - (nope)
  • 2.1 β€” - (nope)
  • 3.0 β€” - (nope)
  • 3.1 β€” - (nope)
  • 3.2 β€” - (nope)
  • 3.3 β€” - (nope)
  • 4.0 β€” - (nope)
  • 4.1 β€” - (nope)
  • 4.2 β€” - (nope)
  • 4.3 β€” - (nope)
  • 4.4 β€” βœ” (slay!!)
  • 4.5 β€” βœ” (slay!!)

basically the ✨ era ✨ starts at 4.4 and we do not look back πŸ’œ


🧚 SEE ALSO

glGenSamplers(), glBindSampler(), glDeleteSamplers(), glGet(), glSamplerParameter(), glGetSamplerParameter(), glGenTextures(), glBindTexture(), glDeleteTextures() β€” the whole friend group, go say hi 🫢


Copyright Β© 2013-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 Β© 2013-2014 Khronos Group


and that's the whole page, bestie πŸŽ€ source/version is [FIXME: source], dated 08/09/2021, and it ships under the 3G manual β€” mwah, go bind some samplers, periodt πŸ’–βœ¨

πŸ“¦ where this page comes from