PDA

View Full Version : FBO failure



eldritch
12-18-2006, 10:44 AM
I'm using FBO's for rendering to textures. In this case there is no z buffering, just a simple color buffer.

On nvidia cards this seems to work fine under both Linux and Windows. Also on the ATI X1600 on a MacBook pro it also works fine. But on older ATI hardware (9600 XT) on Windows this fails with the enum FRAMEBUFFER_INCOMPLETE_ATTACHMENT from glCheckFramebufferStatusEXT()

This is the relevant code:

(target_ is GL_TEXTURE_2D, width_ is 256, height_ is 128 and z_depth_ is 0)



bool FBOTexture::initBuffers()
{
bool result = true;
// create objects
glGenFramebuffersEXT(1, &fb_); // Frame buffer object
glGenTextures(1, &handle_); // Texture handle
if(z_depth_ > 0)
glGenRenderbuffersEXT(1, &depth_rb_); // Render buffer for z buffering

// Make frame buffer active
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb_);

// Initialize texture
glBindTexture(target_, handle_);
applyTexParameters(target_);

GLenum int_fmt, data_type, data_fmt;
GngImage::Format new_fmt = getGLFormat(pixel_fmt_, int_fmt, data_fmt, data_type);
if(new_fmt != pixel_fmt_)
{
pixel_fmt_ = new_fmt;
getGLFormat(pixel_fmt_, int_fmt, data_fmt, data_type);
}
glTexImage2D(target_, 0, GL_RGBA8, width_, height_, 0, data_fmt, data_type, (GLvoid*)NULL);

// Establish a mipmap chain
if(min_filter_ != GL_NEAREST &&
min_filter_ != GL_LINEAR)
glGenerateMipmapEXT(target_);

// Attach texture to framebuffer color buffer
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target_, handle_, 0);

// Initialize depth renderbuffer
if(z_depth_ > 0)
{
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb_);
GLenum depth_fmt = GL_DEPTH_COMPONENT;
if(z_depth_ == 16)
depth_fmt = GL_DEPTH_COMPONENT16;
else if(z_depth_ == 24)
depth_fmt = GL_DEPTH_COMPONENT24;
else if(z_depth_ == 32)
depth_fmt = GL_DEPTH_COMPONENT32;
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depth_fmt, width_, height_);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb_);
}

// Check framebuffer status
GLuint status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if(status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
logError() << "GngFBOTexture: initBuffers() failed, FBO not complete!: " << endl;
result = false;
switch(status)
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
logError() << "Reason: FRAMEBUFFER_INCOMPLETE_ATTACHMENT" << endl;
break;

... more cases...

}
}

// Set rendering to window
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

return result;
}
If anyone has any ideas, I'd be overjoyed :-)

Cheers!