PDA

View Full Version : Framebuffer failure on Intel HD3000



Kopelrativ
09-06-2012, 09:50 PM
I am setting up a shadow map, as follows. But I get the error GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER. I am using a draw buffer, not a read buffer, how should I interpret this?

Also, the specification says I get this if "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE​ is GL_NONE​ for any color attachment point(s) named by GL_DRAWBUFFERi​.". Setting aside the draw/read inconsistency, I wonder if you are required to call glReadBuffer() and glDrawBuffers() when setting up a FBO GL_FRAMEBUFFER?



glGenTextures(1, &fTexture);
glBindTexture(GL_TEXTURE_2D, fTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, fMapWidth, fMapHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
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_COMPARE_MODE, GL_NONE);
glBindTexture(GL_TEXTURE_2D, 0);


glGenFramebuffers(1, &fboName);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboName);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, fTexture, 0);
glDrawBuffer (GL_NONE);
glReadBuffer(GL_NONE);
auto result = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
if (result != GL_FRAMEBUFFER_COMPLETE) {
ErrorDialog("ShadowRender::Init: Framebuffer is not complete: %s\n", FrameBufferError(result));
exit(1);
}
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);


Vendor: Intel
Renderer: Intel(R) HD Graphics 3000
Version: 3.1.0 - Build 8.15.10.2761
GLSL: 1.40 - Intel Build 8.15.10.2761
OpenGL context version parsed by GLFW: 3.1.0

arekkusu
09-07-2012, 08:58 AM
This is an easy mistake to make.

[Draw, Read]Buffer set framebuffer state. But which framebuffer?
DrawBuffer sets state in the fbo currently bound to DRAW_FRAMEBUFFER_BINDING, which is your fboName.
ReadBuffer sets state in the fbo currently bound to READ_FRAMEBUFFER_BINDING, which you haven't set in your shown code, so is probably the window.

Then you query the completeness of DRAW_FRAMEBUFFER, and it's incomplete, because its read buffer is still set to the default COLOR_ATTACHMENT0, which is missing.

Solution: while creating your FBOs, always bind FRAMEBUFFER, so both read and draw state can be set.
Only bind DRAW_FRAMEBUFFER and READ_FRAMEBUFFER when you're using the fbos, i.e. rendering/reading/blitting.


Also note that newer versions of OpenGL (~4.2 or ARB_ES2_compatibility) would have said your framebuffer was complete because the missing draw/read buffer error has been removed from the specification. But read operations on this fbo (i.e. blit) would not work like you expect.

Kopelrativ
09-07-2012, 01:00 PM
This is an easy mistake to make.

[Draw, Read]Buffer set framebuffer state. But which framebuffer?
DrawBuffer sets state in the fbo currently bound to DRAW_FRAMEBUFFER_BINDING, which is your fboName.
ReadBuffer sets state in the fbo currently bound to READ_FRAMEBUFFER_BINDING, which you haven't set in your shown code, so is probably the window.

Then you query the completeness of DRAW_FRAMEBUFFER, and it's incomplete, because its read buffer is still set to the default COLOR_ATTACHMENT0, which is missing.

Solution: while creating your FBOs, always bind FRAMEBUFFER, so both read and draw state can be set.
Only bind DRAW_FRAMEBUFFER and READ_FRAMEBUFFER when you're using the fbos, i.e. rendering/reading/blitting.

Thanks for the suggestion, that solved the issue!


Also note that newer versions of OpenGL (~4.2 or ARB_ES2_compatibility) would have said your framebuffer was complete because the missing draw/read buffer error has been removed from the specification. But read operations on this fbo (i.e. blit) would not work like you expect.
I suppose that is why I only had the error with Intel, being of version 3.1.