GLGETSHADERSOURCE(3G)
β¨ GLGETSHADERSOURCE β¨
okay so this is the 3G page from the OpenGL manual (the header literally says [FIXME: manual], which, like, same bestie π) and it's all about pulling the source code string back out of a shader object. no cap, it's a whole vibe check on your shader's receipts π
πΈ NAME πΈ
glGetShaderSource β returns the source code string from a shader object π«Ά
π» C SPECIFICATION π»
void glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length,
GLchar *source);
π PARAMETERS π
shaderβ the shader object you're querying, bestie. point at it. πbufSizeβ the size of the character buffer you're stuffing the returned source code string into π¦lengthβ returns the length of the string that came back insource(and not counting that null terminator, we don't count him π)sourceβ an array of characters, and it's where the source code string comes home to roost π
π¦ DESCRIPTION π¦
glGetShaderSource returns the concatenation of the source code strings from the shader object specified by shader. literally just gluing them all together for you π§
the source code strings for a shader object are the result of a previous call to glShaderSource(). so like, it's giving "you gave me the shader, now I give you the words back". the string returned by the function will be null terminated β periodt.
glGetShaderSource returns in source as much of the source code string as it can, up to a maximum of bufSize characters. key word: as much as it can. it's not gonna overflow for you, she has boundaries π
the number of characters actually returned, excluding the null termination character, is specified by length. and if you don't care about the length of the returned string? that's so valid of you β just pass a value of NULL in the length argument. iconic, low-effort, we love. π
the size of the buffer required to store the returned source code string can be obtained by calling glGetShader() with the value GL_SHADER_SOURCE_LENGTH. do that FIRST, okay? like measure before you buy the dress π
π ERRORS π
GL_INVALID_VALUEis generated ifshaderis not a value generated by OpenGL. (not me catching you making up shader names π)GL_INVALID_OPERATIONis generated ifshaderis not a shader object. right object, wrong type, classic.GL_INVALID_VALUEis generated ifbufSizeis less than 0. negative buffer? in THIS economy?? bestie no π«
π ASSOCIATED GETS π
glGetShader()with argumentGL_SHADER_SOURCE_LENGTHglIsShader()
π VERSION SUPPORT π
glGetShaderSource is supported in every OpenGL version listed here, and yes she's been booked and busy since 2.0 β. the function name is glGetShaderSource and here's the full run-down:
- OpenGL 2.0 β β
- OpenGL 2.1 β β
- OpenGL 3.0 β β
- OpenGL 3.1 β β
- OpenGL 3.2 β β
- OpenGL 3.3 β β
- OpenGL 4.0 β β
- OpenGL 4.1 β β
- OpenGL 4.2 β β
- OpenGL 4.3 β β
- OpenGL 4.4 β β
- OpenGL 4.5 β β
(that's the "OpenGL Version" row and the "Function / Feature Name" row, babes β twelve for twelve, ate and left no crumbs π₯)
π SEE ALSO π
glCreateShader()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
and that's the whole page, bestie π stay hydrated, null-terminate your strings, and remember: bufSize is a limit, not a suggestion π
so yeah β this came from [FIXME: source], dated 08/09/2021, and it's page GLGETSHADERSOURCE(3G) all the way down. mwah π
β¨
π¦ 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