Direct State AccessGL 4.5

glCreateFramebuffers

Creates framebuffer objects that exist immediately, ready for glNamedFramebuffer* calls.

Part of the family glCreate*

Signature

void glCreateFramebuffers(GLsizei n, GLuint *framebuffers);

How it works

The DSA replacement for glGenFramebuffers. A new framebuffer has no attachments, so it is incomplete until you attach at least one image; you never need to bind it to set it up, only to draw into it (glBindFramebuffer).

Parameters

nGLsizei

How many.

framebuffersGLuint *

Array receiving the IDs.

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.

  • Delete with glDeleteFramebuffers; the attached textures are not deleted with it.

Example

example.cpp
1GLuint fbo;
2glCreateFramebuffers(1, &fbo);
3glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0, colorTex, 0);
Official Khronos documentation