So I’m still trying to get the hang of frame buffer objects and the one thing I still don’t quite understand is the world points in reference to the FBO.
So assuming I’m in a 2D environment and there’s objects drawn behind the FBO (not in FBO) and object above FBO (draw inside FBO), how do I deal with the world bounds when the FBO looking off screen? So basically I’m using FBO similar to photo-shop with layers.
So lets say the “camera” is looking into the world with bounds
(-2,-2) to (2,2) and the FBO has the bounds (1,-1) to (3,1). Drawing is easy as you just treat it as a texture, but my problem stems from drawing to the buffer, especialy since the objects above draw function behaves the same way regardless of what’s below. So what do I need to put in the blank sections in the below code.
void layer::drawToBuffer()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
//how do I setup the bounds, viewport, etc?
//how do I clear the buffer?
drawAbove();
//how do I restore the original world bounds and other values.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}