Capture part of FBO to texture

Another somewhat simple question.
I have a fbo and I need to capture a rectangular section from it and save it into a texture.
(sort of crop). So I have x,y, width and height (corresponds to ofTexture allocation). What would be the best way to do it ?

Something similar to loadScreenData, but that takes fbo as a source ?


ofFbo has a texture inside of it –


also ofTexture has a “drawSubsection” function which takes a drawing position and texture position, so you could combine them with


If you want to save it to an image, you can also use ofFbo.readToPixels and pass in an ofImage, either directly or .getPixels() I forget. I think u might need to call .update on the ofImage after as well.

I’ve discovered both, but not sure how to combine them actually.
I need transfer part of fbo (or it’s texture) to another texture (not fbo).
Since I can’t draw on texture, I’m not sure how drawSubsection() can be used in this case…

but readToPixels() seems to ready everything, not just a cropped section… right ?

Could draw to the dst texture and just use a quad mesh with the texcoords you want or a cropped viewport?

Fbos can have multiple textures or use another fbo, so you can render to texture with that.

yeah, thanks.
I ended up using fBO as suggested… I write using draw and supplying x,y offset and then get texture from it.