GLCREATESHADERPROGRA(3G)

🌸 glCreateShaderProgramv πŸ’…

okay bestie, buckle up β€” this is the 3G manual page for glCreateShaderProgramv, and it's honestly kind of a serve. it's the OpenGL girlie that builds you a whole stand-alone program out of an array of null-terminated source code strings. yes, that's a mouthful, but we move. ✨


✨ NAME ✨

glCreateShaderProgramv β€” create a stand-alone program from an array of null-terminated source code strings 🫢


πŸŽ€ C SPECIFICATION πŸŽ€

okay so this is literally the whole signature, copy it exactly, do NOT freestyle:

GLuint glCreateShaderProgramv(GLenum type, GLsizei count,
                              const char **strings);

πŸ’œ PARAMETERS πŸ’œ

  • type β€” tells the universe which type of shader you're trying to create.
  • count β€” how many source code strings are chillin' in the strings array.
  • strings β€” the address of an array of pointers to source code strings. that's the raw material the program object gets built from, no cap.

πŸ¦‹ DESCRIPTION πŸ¦‹

so glCreateShaderProgram (yes it's spelled without the v in the prose, that's just how it is, don't come for me) creates a program object containing compiled and linked shaders for a single stage, and that stage is whatever you passed as type. strings points at an array of count strings, and those strings are where the shader executables come from. iconic.

here's the tea: glCreateShaderProgram is equivalent to the following, assuming no errors get generated:

const GLuint shader = glCreateShader(type);
if (shader) {
    glShaderSource(shader, count, strings, NULL);
    glCompileShader(shader);
    const GLuint program = glCreateProgram();
    if (program) {
        GLint compiled = GL_FALSE;
        glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
        glProgramParameteri(program, GL_PROGRAM_SEPARABLE, GL_TRUE);
        if (compiled) {
            glAttachShader(program, shader);
            glLinkProgram(program);
            glDetachShader(program, shader);
        }
        /* append-shader-info-log-to-program-info-log */
    }
    glDeleteShader(shader);
    return program;
} else {
    return 0;
}

and the program object that glCreateShaderProgram hands you back has its GL_PROGRAM_SEPARABLE status set to GL_TRUE. periodt. πŸ‘‘


πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM gets generated when type isn't an accepted shader type. rude but fair.
  • GL_INVALID_VALUE gets generated when count is negative. bestie, negative? no. πŸ™ˆ
  • other errors get generated if the shader code you supplied fails to compile and link β€” exactly as described for the commands in the pseudocode sequence up above. but here's the important part, don't skip it: all of those errors are generated without any side effects of executing those commands. so it's like, ghost errors. they show up, but nothing actually happened. 🧚

🌈 VERSION SUPPORT 🌈

so the chart says glCreateShaderProgramv is a late bloomer β€” she does not exist in the earlier versions. here's the vibe check per version:

  • OpenGL 2.0 β€” - (nope)
  • OpenGL 2.1 β€” - (nope)
  • OpenGL 3.0 β€” - (nope)
  • OpenGL 3.1 β€” - (nope)
  • OpenGL 3.2 β€” - (nope)
  • OpenGL 3.3 β€” - (nope)
  • OpenGL 4.0 β€” - (nope)
  • OpenGL 4.1 β€” βœ” (she's here!!)
  • OpenGL 4.2 β€” βœ”
  • OpenGL 4.3 β€” βœ”
  • OpenGL 4.4 β€” βœ”
  • OpenGL 4.5 β€” βœ”

main character energy starting at 4.1, we love a glow-up. ⭐


🌸 SEE ALSO 🌸

go read these too, iykyk:

  • glCreateShader()
  • glCreateProgram()
  • glCompileShader()
  • glLinkProgram()

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


and that's the whole page, bestie πŸ’– ok so for the cute sign-off: this one came from [FIXME: source], dated 08/09/2021, and it's page GLCREATESHADERPROGRA(3G) β€” slay, go compile something. πŸŽ€βœ¨

πŸ“¦ where this page comes from