GLGETPROGRAMBINARY(3G)

🌸 GLGETPROGRAMBINARY πŸ’…

okay so real talk, this one lives in the 3G corner of the manual (that's the OpenGL section bestie, don't @ me) and it's genuinely such a useful little function. it's glGetProgramBinary and it's about to hand you your whole compiled+linked program as a raw binary blob. slay.

✨ NAME ✨

glGetProgramBinary β€” return a binary representation of a program object's compiled and linked executable source πŸŽ€

✨ C SPECIFICATION ✨

like, this is the exact signature, no cap, copy it character for character:

void glGetProgramBinary(GLuint program, GLsizei bufSize,
                        GLsizei *length, GLenum *binaryFormat,
                        void *binary);

✨ PARAMETERS ✨

  • program β€” the name of the program object whose binary representation you wanna retrieve. that's your main character right there πŸ‘‘
  • bufSize β€” the size of the buffer whose address is given by binary. aka how much room you're giving it.
  • length β€” the address of a variable that receives the number of bytes actually written into binary. it's giving "receipts" πŸ’…
  • binaryFormat β€” the address of a variable that receives a token indicating the format of the binary data the GL returned. iykyk πŸ¦‹
  • binary β€” the address of an array into which the GL will return the program's binary representation. this is where the good stuff lands ✨

✨ DESCRIPTION ✨

okay so glGetProgramBinary returns a binary representation of the compiled and linked executable for program, dropping it into the array of bytes whose address is specified in binary. iconic behavior, honestly.

the maximum number of bytes that may be written into binary is specified by bufSize. and here's the important bit bestie β€” if the program binary is greater in size than bufSize bytes, then an error is generated 😭 otherwise the actual number of bytes written into binary gets returned in the variable whose address is given by length. and if length is NULL, then no length is returned. no vibe check, no receipt, it just doesn't tell you.

the format of the program binary written into binary is returned in the variable whose address is given by binaryFormat, and it may be implementation dependent β€” so like, don't assume it's the same everywhere, fr fr πŸ™ˆ

the binary the GL produces may subsequently be returned to the GL by calling glProgramBinary(), with binaryFormat and length set to the values returned by glGetProgramBinary, and passing the returned binary data in the binary parameter. it's a whole round trip and it ate πŸ”₯

✨ ERRORS ✨

heads up bestie, these two will absolutely ruin your day if you're not paying attention πŸ’€
  • GL_INVALID_OPERATION is generated if bufSize is less than the size of GL_PROGRAM_BINARY_LENGTH for program.
  • GL_INVALID_OPERATION is generated if GL_LINK_STATUS for the program object is false. like, if it didn't link, there's nothing to give you, periodt.

✨ ASSOCIATED GETS ✨

glGetProgram() with argument GL_PROGRAM_BINARY_LENGTH 🫢

✨ VERSION SUPPORT ✨

so the original ships a big sparkly grid of OpenGL versions here β€” i can't draw you the box, but the facts are literally the same, no cap. glGetProgramBinary is not supported in OpenGL 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, or 4.0 (all -), and it is supported in OpenGL 4.1, 4.2, 4.3, 4.4, and 4.5 (all βœ”) ✨

  • 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 β€” βœ”

✨ SEE ALSO ✨

glGetProgram(), glProgramBinary() β€” go read those too, they're the supporting cast and they understood the assignment πŸ’–

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


okay that's the whole page bestie, go compile something gorgeous πŸ’…βœ¨

🌸 mwah, this rewrite was brought to you by [FIXME: source], dated 08/09/2021, and the original GLGETPROGRAMBINARY(3G) header/footer energy β€” see u in the group chat 🫢🌈

πŸ“¦ where this page comes from