Direct State AccessGL 4.5

glCheckNamedFramebufferStatus

Tells whether a framebuffer is complete (ready to draw into) and, if not, why.

Signature

GLenum glCheckNamedFramebufferStatus(GLuint framebuffer, GLenum target);

How it works

Drawing into an incomplete framebuffer does nothing and raises GL_INVALID_FRAMEBUFFER_OPERATION. Check once after setting up the attachments; anything other than GL_FRAMEBUFFER_COMPLETE names the problem.

Parameters

framebufferGLuint

The framebuffer to check.

targetGLenum

GL_FRAMEBUFFER (or GL_DRAW_FRAMEBUFFER / GL_READ_FRAMEBUFFER).

Return value

GL_FRAMEBUFFER_COMPLETE, or the reason: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT (an image without storage or of a format that cannot be rendered), GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT (nothing attached), GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE (sample counts differ), GL_FRAMEBUFFER_UNSUPPORTED (this combination of formats is not supported by the driver).

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.

Example

example.cpp
1if (glCheckNamedFramebufferStatus(fbo, GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
2    std::cerr << "framebuffer incomplete\n";
Official Khronos documentation