GLATTACHSHADER(3G)

πŸ’… GLATTACHSHADER πŸ’…

okay so bestie, welcome to the glAttachShader(3G) page β€” yes that 3G is the manual section, it's giving OpenGL library realness, we love that for us ✨

🌸 NAME 🌸

glAttachShader β€” attaches a shader object to a program object. that's it, that's the whole job, and it does it flawlessly πŸ’–

πŸŽ€ C SPECIFICATION πŸŽ€

void glAttachShader(GLuint program, GLuint shader);

literally the whole signature, no cap 🫢

πŸ¦‹ PARAMETERS πŸ¦‹

  • program β€” the program object that a shader object is gonna get attached to. this is the main character here πŸ‘‘
  • shader β€” the shader object that's about to be attached. this one's the plus-one πŸ’…

πŸ”₯ DESCRIPTION πŸ”₯

okay so, to build a complete shader program you have to have a way to say which things get linked together β€” and program objects are literally that mechanism, no notes. shaders that are gonna be linked together in a program object have to be attached to that program object first, periodt. glAttachShader takes the shader object you passed as shader and attaches it to the program object you passed as program. which basically means "hey, include this shader in the link operations that'll be performed on program" 🫢

and here's the slay part: every operation you can do on a shader object is valid whether or not it's attached to a program object. so it's totally permissible to attach a shader object to a program object before source code has been loaded into the shader object, or before the shader object has been compiled. iconic, lowkey unbothered behavior ✨

it's also permissible to attach multiple shader objects of the same type, because each one may contain a portion of the complete shader β€” teamwork, we stan 🌈

and it's permissible to attach a shader object to more than one program object too, because why gatekeep πŸ’œ

⚠️ but listen: if a shader object gets deleted while it's still attached to a program object, it will be flagged for deletion β€” and that deletion will not actually occur until glDetachShader() is called to detach it from all program objects it's attached to. so it's not gone-gone yet, it's just on the list 😭

πŸ’€ ERRORS πŸ’€

  • GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL. (rude, but okay πŸ™ˆ)
  • GL_INVALID_OPERATION is generated if program is not a program object.
  • GL_INVALID_OPERATION is generated if shader is not a shader object.
  • GL_INVALID_OPERATION is generated if shader is already attached to program. we said no double-dipping bestie πŸ’…

⭐ ASSOCIATED GETS ⭐

  • glGetAttachedShaders() with the handle of a valid program object
  • glGetShaderInfoLog()
  • glGetShaderSource()
  • glIsProgram()
  • glIsShader()

πŸ‘‘ VERSION SUPPORT πŸ‘‘

so the original page ships this as a big pretty grid, and we're translating it into vibes: the function/feature name is glAttachShader, and across every single OpenGL version listed β€” 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5 β€” the checkmark is a full βœ”. yes, all twelve. she ate and left no crumbs πŸ”₯

🧚 SEE ALSO 🧚

  • glCompileShader()
  • glCreateShader()
  • glDeleteShader()
  • glDetachShader()
  • glLinkProgram()
  • glShaderSource()

Copyright Β© 2003-2005 3Dlabs Inc. Ltd. Copyright Β© 2010-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 Β© 2003-2005 3Dlabs Inc. Ltd. Copyright Β© 2010-2014 Khronos Group


k bye bestie, the manual header is GLATTACHSHADER(3G) and the footer is giving source [FIXME: source] with the date 08/09/2021 β€” those two lil' placeholders are literally in the original, i'm just passing them along verbatim, don't come for me 😭🫢

πŸ“¦ where this page comes from