Best way to edit fbo content position?

Hello. I’m trying to do this:

I have an FBO with some drawings in it
1-01

I want to divide it in two, for now it is ok…
1-02

Now I need to copy the cutout B to the cutout A location and get the part C (previously B) cleared.
1-03

What would be the most efficient way to do that?
Thank you.

#fbo #ofFbo #move #position #copy #paste #clear

I did this but I don’t know… I think there should be a better way.

ofPixels pix;
ofImage img;
fbo.begin();
fbo.readToPixels(pix);
img.setFromPixels(pix);
ofClear(255,255);
img.draw(-ofGetWidth(), 0);
fbo.end();

I would use two FBOs, and copy one area to another using fbo.getTexture()->drawSubsection(…)

there are different ways of using drawSubsection and my favorite is using two ofRectangles as parameter, so you can choose the copy and paste area.

It is not a complete solution as it is not clear of what you are trying to accomplish with your entire program.

1 Like

thank you! I’l give it a try.

It is not a complete solution as it is not clear of what you are trying to accomplish with your entire program.

I’m making a game with a scrolling background where the shape the player controls is drawn in each frame leaving its tail

Video_21-07-15_23-09-02_1_1

The tail is loaded in the FBO and the FBO scrolls its x position, when it reaches its width limit the scroll position goes back to zero and there is where this algorithm take place

1 Like