FBO is Framebuffer Object,
You create and setup it like that:
GLuint myFBOs[NUM_FBOS];
GLuint depthBuffers[NUM_FBOS];
GLuint textures[NUM_FBOS];
glGenFramebuffers( NUM_FBOS, myFBOs );
glGenRenderbuffers( NUM_FBOS, depthBuffers );
glGenTextures( NUM_FBOS, textures );
for(int i = 0;i < NUM_FBOS;i++)
{
glBindFramebuffer( GL_FRAMEBUFFER, myFBOs[i] );
glBindRenderbuffer( GL_RENDERBUFFER, depthBuffers[i] );
glBindTexture( GL_TEXTURE_2D, textures[i] );
/*setup texture format and parameters, eg:*/
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
/*setup depth buffer IT MUST HAVE THE SAME width and height as texture*/
glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height );
/*attach texture and depth buffer to FBO*/
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[i], 0 );
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffers[i] );
/*check status*/
if( glCheckFramebufferStatus( GL_FRAMEBUFFER ) != GL_FRAMEBUFFER_COMPLETE)
printf( "Something is wrong with your FBO setup!
" );
}
now your FBOs are ready to rendering, to render to FBO:
bind it:
glBindFramebuffer( GL_FRAMEBUFFER, myFBOs[whichever_you_want] );
(don’t forget to set Your viewport to texture dimensions)
and everything that You render will go to texture attached to that fbo.
If You want to render to screen, unbind FBO:
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
and You may now use textures attached to FBOs to draw your windows. (set orhographic projection and draw just textured quads (or apply some custom transformations to them, choice is yours
))
When any of your windows requests update, just bind it’s FBO, redraw, unbind FBO and redraw main dialog (for me it works fast enough).