About render buffers

What is the difference between glGenRenderBuffers and glCreateRenderBuffers (4.5) , why was this introduced?

glGen* functions are part of legacy OpenGL - they don’t create objects, they just return an unused object name, and creation is deferred to first time the object is bound.

glCreate* functions are part of Direct State Access and actually create a default object of the appropriate type as well as giving it a name.

The rationale for this is described in the documentation for GL_ARB_direct_state_access: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_direct_state_access.txt

…in unextended OpenGL, only binding functions created objects (bind-to-create), even if their names were obtained through one of the glGen* functions. This extension does not allow on-the-spot creation of objects. Rather than rely on bind-to-create (which would defeat the purpose of the extension), we add glCreate* functions that produce new names that represent state vectors initialized to their default values…

glGen* functions only allocate the names; the object isn’t created until the name is bound (in the case of renderbuffers, with glBindRenderbuffer). glCreate* functions allocate the name and create the object, initialised to its default state.

To elaborate on both the previous answers: The DSA extension added the glCreate* functions because DSA eliminates the need to bind objects before using them. If you call glGenRenderbuffers followed by e.g. glNamedRenderbufferStorage, the latter will generate an error because the name returned from the former doesn’t, at that point, refer to a renderbuffer object. You would need to call glBindRenderbuffer to actually create the renderbuffer object before passing the name to the glNamedRenderbuffer* functions.

The same issue applies to other object types with glGen* and glCreate* functions.