using glFramebufferRenderbuffer to clear color attachment

A fbo may have a color attachment bound with a variety of different functions, including: glFramebufferRenderbuffer, glFramebufferTexture2D, glFramebufferTexture2DMultisampleEXT.

To clear the color attachment, is it safe to just always use glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENTX, GL_RENDERBUFFER, 0) or does it have to be cleared with the same function it was originally bound with? If it’s the latter then it raises some questions like what should be passed for the number of samples in the Texture2DMultisample case.

This sentence in the ES reference makes me think that maybe it’s OK to just use FramebufferRenderbuffer?

“If renderbuffer is 0, the current image, if any, attached to the attachment logical buffer of the currently bound framebuffer object is detached.”

Looking through the spec (, it states that when 0 is attached, it sets the state for the attachment point are set to their default values.
Page 271, for FrameBufferTexture2D.

The table of defaults is 23.25

The page you link to states in its description section what happens when 0 is attached. Those values are the default values found in table 23.25

I didn’t see FramebufferTexture2DMultisample so I can’t speak for that one. But it would appear if you created an fbo it would be safe to clear it with either FramebufferRenderbuffer or FramebufferTexture2d