GLGETBUFFERPOINTERV(3G)

πŸ’… GLGETBUFFERPOINTERV β€” the 3G girlies are back at it

okay so bestie, picture this: you mapped a buffer, the driver handed you a whole pointer, and now you're like "wait… what was that pointer again??" 😭 That's literally the entire plot of this page. glGetBufferPointerv and glGetNamedBufferPointerv hand you back the pointer to a mapped buffer object's data store. No cap, that's it. πŸŽ€


✨ C SPECIFICATION ✨

void glGetBufferPointerv(GLenum target, GLenum pname, GLvoid ** params);

void glGetNamedBufferPointerv(GLuint buffer, GLenum pname,
                              void **params);

🌸 PARAMETERS 🌸

  • target β€” the target the buffer object is bound to for glGetBufferPointerv. It must be one of the buffer binding targets from this little table of ours (yes I turned the table into a list, the vibes demanded it πŸ’…):
    • GL_ARRAY_BUFFER β€” vertex attributes
    • GL_ATOMIC_COUNTER_BUFFER β€” atomic counter storage
    • GL_COPY_READ_BUFFER β€” buffer copy source
    • GL_COPY_WRITE_BUFFER β€” buffer copy destination
    • GL_DISPATCH_INDIRECT_BUFFER β€” indirect compute dispatch commands
    • GL_DRAW_INDIRECT_BUFFER β€” indirect command arguments
    • GL_ELEMENT_ARRAY_BUFFER β€” vertex array indices
    • GL_PIXEL_PACK_BUFFER β€” pixel read target
    • GL_PIXEL_UNPACK_BUFFER β€” texture data source
    • GL_QUERY_BUFFER β€” query result buffer
    • GL_SHADER_STORAGE_BUFFER β€” read-write storage for shaders
    • GL_TEXTURE_BUFFER β€” texture data buffer
    • GL_TRANSFORM_FEEDBACK_BUFFER β€” transform feedback buffer
    • GL_UNIFORM_BUFFER β€” uniform block storage
  • buffer β€” the name of the buffer object for glGetNamedBufferPointerv. (the "named" one, she's the DSA sister πŸ¦‹)
  • pname β€” the name of the pointer you want returned. It must be GL_BUFFER_MAP_POINTER. like, there is no other option, she's the only one at the party πŸ’€
  • params β€” where the pointer value specified by pname comes back to you 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

glGetBufferPointerv and glGetNamedBufferPointerv return the buffer pointer pname, which must be GL_BUFFER_MAP_POINTER. The single buffer map pointer comes back in params.

And here's the part where you go "wait, NULL??" β€” a NULL pointer is returned in two situations, and I need you to actually read them bestie:

  • if the buffer object's data store is not currently mapped, or
  • if the requesting context did not map the buffer object's data store, and the implementation is unable to support mappings on multiple clients.

so yeah, NULL is not always a you-problem, sometimes the driver just said "not today" πŸ™ˆ


πŸ¦‹ NOTES πŸ¦‹

  • If an error is generated, no change is made to the contents of params. (she protects your pointer, queen behavior πŸ”₯)
  • The initial value for the pointer is NULL.
  • The GL_ATOMIC_COUNTER_BUFFER target is available only if the GL version is 4.2 or greater.
  • The GL_DISPATCH_INDIRECT_BUFFER and GL_SHADER_STORAGE_BUFFER targets are available only if the GL version is 4.3 or greater.
  • The GL_QUERY_BUFFER target is available only if the GL version is 4.4 or greater.

πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM is generated by glGetBufferPointerv if target is not one of the accepted buffer targets, or if pname is not GL_BUFFER_MAP_POINTER.
  • GL_INVALID_OPERATION is generated by glGetBufferPointerv if zero is bound to target. (zero is literally nobody, do not bind her 😭)
  • GL_INVALID_OPERATION is generated by glGetNamedBufferPointerv if buffer is not the name of an existing buffer object.

🌈 VERSION SUPPORT 🌈

the whole OpenGL version lineup is 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5 β€” and here's who showed up to which πŸ’–

  • glGetBufferPointerv β€” βœ” for every single one: 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5. she's been here since day one and she never left, iconic ⭐
  • glGetNamedBufferPointerv β€” - for 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, and βœ” only for 4.5. she's a late bloomer and we love her for it 🧚

πŸŽ€ SEE ALSO πŸŽ€

  • glBindBuffer()
  • glMapBuffer()

go read those next, iykyk πŸ’œ


Copyright Β© 2005 Addison-Wesley. Copyright Β© 2011-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 Β© 2005 Sams Publishing Copyright Β© 2011-2014 Khronos Group


okay that's the whole page, mwah πŸ“ sign-off time: this one came from [FIXME: source], stamped 08/09/2021, and it lives under the name GLGETBUFFERPOINTERV(3G) β€” go map something and slay, bestie πŸ’…βœ¨

πŸ“¦ where this page comes from