openglpbo

Can I create PBO in this way?


To create a buffer in OpenGL, we need to write following code down:

GLuint buffer;
glCreateBuffers(1,&buffer);
glNamedBufferStorage(buffer,size,data,flags);

I know that we can create a PBO in this way:

GLuint pbo;
glCreateBuffers(1,&pbo);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,&pbo);
glBufferData(...);//initializing buffer

my question is, can I create pbo in the first manner?


Solution

  • There is no such thing as a "PBO"; at least, not in the way you seem to regard it. There are just buffer objects, and being the source/destination of a pixel transfer is merely one usage of them. A buffer object is in no way directly associated with any particular use of it.

    You can use a buffer object for a pixel transfer, then use the same one for vertex data, then use the same one for something else. Or you can use different parts of a buffer object for different usages. OpenGL does not care. Any buffer can be used for any of the things a buffer can be used for at any time (within certain sane restrictions).

    The buffer you created with the DSA APIs can be used for pixel transfers just like any other buffer object.