Hello guys,
I wrote a small tutorial with a minimal set of OGL FBO APIs that will demonstrate how FBO works.
here it is:
void init( void )
{
// Create a frame-buffer object
glGenFramebuffersEXT( 1, &fboId );
// Generate a texture (will be used to draw into it)
glGenTextures( 1, &texId );
// Bind the texture and…
glBindTexture( GL_TEXTURE_2D, texId);
// Allocate memory in the server without passing data (the data
// will be fragments drawn to it!)
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0 );
// Now:
// 1. Bind frame buffer
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId );
// 2. Attach the texture to the frame buffer, so when we choose the frame buffer as the drawing
// surface we actually draw to the color buffer attached which is the texture
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texId, 0 );
// Need this line. Without it checkError returns ‘GL_FRAMEBUFFER_UNSUPPORTED_EXT’ !?
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
}
the main drawing loop is very simple and alternate between drawing to the texture by binding the FBO:
// Choose the offscreen frame buffer for rendering
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId );
//check for errors
checkErrors();
drawing…
and unbinding it with:
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
and using the texture.
Now the question:
Without calling (once!)
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
after attaching the texture as a color buffer to the FBO I get ‘GL_FRAMEBUFFER_UNSUPPORTED_EXT’ error.
I don’t know why I get this error. What is the relation between texture filtering mode and the unsupported FBO format? Does I violate some OGL rule or is it an error in the driver (NVIDIA FX 5700)?
Many thanks,
Yossi