GLCREATESHADER(3G)

πŸŽ€ GLCREATESHADER(3G) πŸŽ€

okay so bestie, we're in the 3G manual today, and this little icon is glCreateShader β€” literally the function that makes shader objects out of thin air. let's get into it πŸ’…


✨ NAME ✨

glCreateShader β€” creates a shader object. that's it, that's the vibe πŸ¦‹


✨ C SPECIFICATION ✨

GLuint glCreateShader(GLenum shaderType);

✨ PARAMETERS ✨

  • shaderType β€” tells the universe what kind of shader you're making. it has to be one of GL_COMPUTE_SHADER, GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER, GL_GEOMETRY_SHADER, or GL_FRAGMENT_SHADER. no substitutions, no "close enough", no cap 🫢

✨ DESCRIPTION ✨

so like, glCreateShader creates an empty shader object and hands you back a non-zero value that you use to reference it later. think of it as a little locker where you're gonna store the source code strings that define a shader πŸ“¦βœ¨

shaderType is what tells it which flavor of shader to create. the page says five types of shader are supported β€” and then lists six, but we're not gonna fight the manpage, we're gonna love it πŸ™ˆ. here's the whole roster:

  • a shader of type GL_COMPUTE_SHADER is intended to run on the programmable compute processor.
  • a shader of type GL_VERTEX_SHADER is intended to run on the programmable vertex processor.
  • a shader of type GL_TESS_CONTROL_SHADER is intended to run on the programmable tessellation processor in the control stage.
  • a shader of type GL_TESS_EVALUATION_SHADER is intended to run on the programmable tessellation processor in the evaluation stage.
  • a shader of type GL_GEOMETRY_SHADER is intended to run on the programmable geometry processor.
  • a shader of type GL_FRAGMENT_SHADER is intended to run on the programmable fragment processor.

and the second you create it, the shader object's GL_SHADER_TYPE parameter gets set to whichever of GL_COMPUTE_SHADER, GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER, GL_GEOMETRY_SHADER or GL_FRAGMENT_SHADER you passed in. it knows what it is. main character energy from birth πŸ‘‘πŸ’–


✨ NOTES ✨

  • like buffer and texture objects, the name space for shader objects may be shared across a set of contexts, as long as the server sides of the contexts share the same address space. if the name space is shared across contexts, then any attached objects β€” and the data associated with those attached objects β€” are shared too. everything's shared. we're all in the group chat πŸ«‚
  • applications are responsible for providing the synchronization across API calls when objects are accessed from different execution threads. so like... you gotta handle that yourself, bestie. it's giving "you're on your own" πŸ’€
  • > GL_COMPUTE_SHADER is available only if the GL version is 4.3 or higher. do not come for it on 4.2, it will not be there πŸ™ˆ

✨ ERRORS ✨

  • this function returns 0 if an error occurs while creating the shader object. zero. nada. nothing. sad girl hours 😭
  • GL_INVALID_ENUM is generated if shaderType is not an accepted value. so if you passed something silly, that's on you πŸ”₯

✨ ASSOCIATED GETS ✨

  • glGetShader() β€” with a valid shader object and the parameter to be queried
  • glGetShaderInfoLog() β€” with a valid shader object
  • glGetShaderSource() β€” with a valid shader object
  • glIsShader()

✨ VERSION SUPPORT ✨

the original had this whole grid situation, but the tea is simple: glCreateShader is a full checkmark girlie across the board πŸ’…βœ…

  • OpenGL 2.0 β€” supported βœ”
  • OpenGL 2.1 β€” supported βœ”
  • OpenGL 3.0 β€” supported βœ”
  • OpenGL 3.1 β€” supported βœ”
  • OpenGL 3.2 β€” supported βœ”
  • OpenGL 3.3 β€” supported βœ”
  • OpenGL 4.0 β€” supported βœ”
  • OpenGL 4.1 β€” supported βœ”
  • OpenGL 4.2 β€” supported βœ”
  • OpenGL 4.3 β€” supported βœ”
  • OpenGL 4.4 β€” supported βœ”
  • OpenGL 4.5 β€” supported βœ”

(the function/feature name in that table was glCreateShader, obviously. it ate. no notes. 🌈⭐)


✨ SEE ALSO ✨

  • glAttachShader()
  • glCompileShader()
  • glDeleteShader()
  • glDetachShader()
  • glShaderSource()

go read those next, i'm obsessed with you learning πŸ§šπŸ’œ


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


okay that's the whole page, go forth and shader βœ¨πŸ’–

and for the cute sign-off bestie: the footer credits [FIXME: source] (iconic placeholder behavior, we respect it) and it's dated 08/09/2021 β€” so this tea is from august ninth, twenty twenty-one. periodt πŸ“πŸ¦‹

πŸ“¦ where this page comes from