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_VALUEis generated if eitherprogramorshaderis not a value generated by OpenGL. (rude, but okay π)GL_INVALID_OPERATIONis generated ifprogramis not a program object.GL_INVALID_OPERATIONis generated ifshaderis not a shader object.GL_INVALID_OPERATIONis generated ifshaderis already attached toprogram. we said no double-dipping bestie π
β ASSOCIATED GETS β
glGetAttachedShaders()with the handle of a valid program objectglGetShaderInfoLog()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 πΈ
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
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms