Basic usage of the class FrameBuffer: ------------------------------------- Initialization: (e.g., in main() after glutCreateWindow()) ---------------------------------------------------------- FrameBuffer *fbo = new FrameBuffer( 512 /* width */, 512 /* height */, GL_RGBA /* format of color buffer */, 1 /* number of color buffers */, 1 /* 1 or 0, has a depth buffer? */, "fbName" /* name of FBO (optional) */ ); if (fbo->CheckFramebufferStatus(0) != GL_FRAMEBUFFER_COMPLETE_EXT) ; /* Then there's an error, so you can't use fbo to render into! */ Drawing into the framebuffer object (FrameBuffer *fbo), in your display routine: -------------------------------------------------------------------------------- fbo->BindBuffer(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); /* clear the buffers */ glViewport( 0, 0, fbo->GetWidth(), fbo->GetHeight() ); /* set drawing area correctly */ /* put gl drawing commands here, like in your display routine */ /* you need not call glutSwapBuffers(), though you might want to call glFlush(); */ fbo->UnbindBuffer(); glViewport( 0, 0, screen_width, screen_height ); /* set viewport back to window size. */ Using the stuff you drew into your Framebuffer Object as a texture: (NOTE: This CANNOT be between fbo->BindBuffer() and fbo->UnbindBuffer()) ------------------------------------------------------------------------------ glBindTexture( GL_TEXTURE_2D, fbo->GetColorTextureID(0) ); // or GetDepthTextureID() glEnable( GL_TEXTURE_2D ); /* draw geometry with texture coordinates */ glDisable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, 0 ); // to make sure you can draw into the texture again!