How to make a framebuffer without a depth attachment?

I’m trying to set up a frame buffer for a blur effect; and so it doesn’t need a depth attachment; but i’m getting an INCOMPLETE_MISSING_ATTACHMENT error, even though i have the depth test disabled. I’d rather not allocate memory for an attachment that does nothing; and if i link into another framebuffer’s attachment then i will break the encapsulation of my classes; how can i fix this?

An FBO needs one of the following to be true:

  1. Have at least one image attached somewhere.
  2. With OpenGL 4.3+/ARB_framebuffer_no_attachment, you must have set the FBO’s GL_FRAMEBUFFER_DEFAULT_WIDTH/HEIGHT parameters.

If you are getting that error, then you’re failing to do both of these things. This has nothing to do with an attachment to the depth attachment slot; it’s about not having any attached image in the FBO at all.

If you feel that your code is really attaching something, then you should build a short example program that proves this to be the case.

void EffectBuffer::WindowResize(uint32_t width, uint32_t height)
	width  = (width + BlockSize-1) / BlockSize;
	height = (height + BlockSize-1) / BlockSize;

	if(width == m_width && height == m_height)

	m_width = width;
	m_height = height;

	// Create Textures
	if(m_textures[0] == 0L)
		glGenTextures(3, m_textures); GL_ASSERT

		SetTexParameters(GL_TEXTURE_2D_ARRAY, m_textures[0]); 
		SetTexParameters(GL_TEXTURE_2D, m_textures[1]); 

		glBindTexture(GL_TEXTURE_BUFFER, m_textures[2]);
		glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, m_vbo[2]); 

	glBindTexture(GL_TEXTURE_2D_ARRAY, m_textures[0]); 
	glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA16UI, width, height, 4, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, nullptr); 

	glBindTexture(GL_TEXTURE_2D, m_textures[1]); 
	glTexImage2D(GL_TEXTURE_2D, 0, GL_R16UI, width*BlockSize, height*BlockSize, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, nullptr); 

	if(m_stencil == 0)
		glGenRenderbuffers(1, &m_stencil);

	glBindRenderbuffer(GL_RENDERBUFFER, m_stencil);
	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_width, m_height);

	if(m_fbo[0] == 0)

		glGenFramebuffers(2, m_fbo);

		glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[0]);
		glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textures[IndexTexture], 0, 0, 0);
		glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, m_textures[IndexTexture], 0, 0, 1);
		glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, m_textures[IndexTexture], 0, 0, 2);
		glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, m_textures[IndexTexture], 0, 0, 3);
		glDrawBuffers(4, g_DrawBuffers);

		assert(glGetError() == GL_NO_ERROR);

		glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[1]);
		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textures[1], 0, 0);
		glDrawBuffers(1, g_DrawBuffers);

		assert(glGetError() == GL_NO_ERROR);
		assert(glGetError() == GL_NO_ERROR); //breaks here

edit: (On Ubuntu with raedon drivers)

This should probably be

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_textures[1], 0);

Thank you! I can successfully render to the first FBO i made in the code, and blit it to the screen. But it does explain why the screen is just black on NVidia hardware… i guess?

In addition to the problem that GClements pointed out, you’re attaching three images to the same attachment here. That’s just overwriting the attachment; it’s not attaching 3 layers.

If you want to do layered rendering, then all attachments have to be layered.

You should enable debug output messages and see what errors you’re getting. The bug GClements fixed for you should have shown up in your errors.