How to make a immutable object

I get a texture from a fbo and assign it to a ofTexture object. then I change what’s inside the fbo. it will automatically change my ofTexture object according to the changes. But I don’t want it to happen.

Can anyone help me?

you need to take a copy of the data in the fbo texture. If you dont they are shared (or both point to the same underlying chunk of texture memory) so changes in one will appear in the other.

You can use ofImage to take a copy, allocate the image and readToPixels from the fbo (or something like that i dont have the docs handy)

Thank you

While @dizzy’s advice of reading back the texture data into ofPixels (RAM) will definitely create another copy of the image, it might not be the most efficient as reading back from the GPU is a costly operation, even more so if repeated in the render loop. You definitely can take a copy in VRAM.

If you provide code in how you “get a texture” and “assign it”, and how you’re using it, we might be able to spot why the behaviour (pointing to the same texture data) does not match your expectations.