Using FBO for offscreen drawings
FBO in computer graphics stands for frame buffer object. This is an offscreen raster buffer where openFrameworks can draw just like on the screen. You can draw something in this buffer, and then draw the buffer contents on the screen. The picture in the buffer is not cleared with each testApp::draw()
calling, so you can use FBO for accumulated drawings.
In openFrameworks, FBO is represented by the class ofFBO
.
The typical scheme of its usage is the following:
Declare an
ofFbo
object,fbo
, in thetestApp
class declaration.ofFbo fbo;
Initialize
fbo
with some size in thetestApp::setup()
function.int w = ofGetWidth(); int h = ofGetHeight(); fbo.allocate( w, h );
Draw something in
fbo
. You can do it not only intestApp::draw()
but also intestApp::setup()
andtestApp::update()
. To begin drawing, callfbo.begin()
. After this, all drawing commands, such asofBackground()
andofLine()
, will draw tofbo
. To finish drawing, callfbo.end()
. For example, to fillfbo
with...