FBO incomplete read buffer

glCheckFramebufferStatusEXT returns GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT for me when I try to create a frame buffer that renders depth to a texture (shadow mapping). Rendering to a color buffer works fine.

The spec does not clearly explain what this error means.

Code:

glGenTextures(1, &texname);
glBindTexture(GL_TEXTURE_2D, texname);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mapsize, mapsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, mapsize, mapsize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);

glGenFramebuffersEXT(1, &framebuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
//glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texname, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texname, 0);

// check status
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);

Try adding this to disable color writing and reading:

glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

Nope, still reports the same error.

See yor code:

 
...
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texname, 0);
...

the correct use of render buffer is:

    
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, buffId);

but i believe isn’t possible to attach the depth buffer to a texture, see the current FBO specs.

@AlexN: I’m sorry. Actually your comment is a correct solution. I erroneously placed those functions before the bind() call rather than after, which of course didn’t help.

It now does work, or at least the FBO status is ok. Not showing correct results yet, which undoubltly still requires some tinkering.

Is this guaranteed to work on ATI (and other) cards as well? I read some discussions on various forums that offered other solutions as well. Though this is the only one that works on my GeForce 6200.

@yalmar: the code is fine AFAIK, with the two mentioned api calls added.

It should work on other cards - I pulled that from example 7 of the spec (http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt), about 1/3 of the way through the document.

I believe certain cards do have issues with what precision the depth texture is, though - if you ask for 24-bit precision (DEPTH_COMPONENT24) it probably won’t work on any older ATI cards (only x1600/x1900 and newer). DEPTH_COMPONENT16 should work in that case.

Sorry, i was mistaken, that code really is fine.