Direct State AccessGL 4.5

glUnmapNamedBuffer

Ends a mapping made with glMapNamedBufferRange, so the GPU can use the buffer again.

Signature

GLboolean glUnmapNamedBuffer(GLuint buffer);

How it works

While a buffer is mapped (without the persistent flag), drawing with it is an error. Unmapping hands it back to the GPU, and the pointer becomes invalid.

Parameters

bufferGLuint

The mapped buffer.

Return value

GL_TRUE normally. GL_FALSE in the rare case the contents were lost while mapped (for example a display mode change); then upload the data again.

Tips & pitfalls

  • Direct State Access (GL 4.5): the object is passed as a parameter, so nothing needs to be bound and no global state is disturbed.

Errors

When the call is invalid it does nothing and sets an error, which glGetError returns:

GL_INVALID_OPERATION
The buffer is not mapped.

Example

example.cpp
1void *p = glMapNamedBufferRange(pbo, 0, size, GL_MAP_READ_BIT);
2memcpy(pixels, p, size);
3glUnmapNamedBuffer(pbo);
Official Khronos documentation