I’m just trying to get the example code from the nVidia pdf working, but I always get a bad result. I’ve looked through the other posts on this forum, and I think I’ve covered everything. Can anyone think of any other gotchas I might have missed?
// ---- Create objects
// framebuffer
glGenFramebuffersEXT( 1, &fb );
// render buffer
glGenRenderbuffersEXT( 1, &depth_rb );
// texture
glGenTextures( 1, &tex );
// bind the fb
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb );
// initialize the texture
glBindTexture( GL_TEXTURE_2D, tex );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA8, GL_UNSIGNED_BYTE, NULL );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
// attach texture to framebuffer color buffer
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0 );
// initialize depth render buffer
//glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );
//glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, w, h );
// attach renderbuffer to framebuffer depth buffer
//glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb );
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
switch ( status ) {
case GL_FRAMEBUFFER_COMPLETE_EXT:
cout << "Framebuffer created successfully" << endl;
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
cerr << "Unsupported framebuffer" << endl;
break;
default:
cerr << "Error creating framebuffer" << endl;
break;
}