I find myself doing a fair amount of drawing into FBOs and was wondering if anyone had a general “do this-don’t do that” set of guidelines or rules for optimization purposes. I find myself often effectively drawing to an FBO inside of an update method, for example.
Perhaps more context will help with the discussion:
I’ve been using the ofxFastFboReader addon for saving FBOs out. I’ve encountered a problem with the addon (which I added to the author’s git repository) but the source code I wrote for the example describes how I typically would draw to an FBO.
allocating/deallocation is fairly expensive stuff so having one ofFbo declared in your class, doing the allocation once in setup() and reusing it in saveImage() will speed you up.
Is there anything I should be concerned about with the larger issue of calling saveImage in the update method? Just want to make sure I’m not “doing it wrong.”
Since you’re saving your image, the reading to pixels that you’re doing in saveImage() is unavoidable, but that is a very slow operation (comparatively) because you need to copy data from the graphics card to the CPU memory space, which is always expensive. Other than avoiding that unless it’s absolutely necessary (for instance in saving to the hard drive), I don’t see anything that looks too wrong in there.