Alternative to using FBO?

I’m using a temporary ofImage to grab an ofImage, crop it to a triangle shape using an FBO, rotate it and then apply that to the original ofImage. This works fine without antialiasing, also with it in portrait. Unfortunately i need it to be landscape and for there to be antialiasing in the app, so… I’m looking around for any alternatives to an FBO or a way of dealing with it so that it doesn’t work. I can share screenshots and/or code if necessary!

If the downsides that it may bring are okay for you, you can load pre-made PNGs that will work as masks.

ok, so instead of drawing a triangle in the FBO to act as the mask i would use a PNG? how would i apply that to the image?
also the triangle size would be variable, so i suppose that would just be a case of scaling the png?

I think the easiest way would be to use ofMesh to create a triangle. Then set the texture coordinates of each corner to be the location in the image you want the triangle to be covering.

Assuming your image is drawn from the top left corner of the screen and isn’t being scaled you could just set the Tex cords to be the same as the vertex positions of the three corners.

Hope that helps!

Yes. ofImage is like a container for things like ofPixels and ofTexture. So you can load your img and your mask and apply the mask like so:


Regarding the size, that’s one of the downsides of not using an FBO. You need to do pixel operations to change the texture and point it again as a mask. And this pixel operation can be quite destructive.

I’m more familiar to shaders and textures (because it’s easier to achieve other stuff like soft edges and so on). But @theo’s solution is the best approach! Go with it! :smiley:

Thanks so much for all of this guys, I’ve tried out a load of things as per your recommendations, bad news - it hasn’t worked, good(ish) news- I’ve tracked the bug down to ofImage .grabScreen whilst in landscape orientation. Is this a bug in the ofImage code, or in how I’m implementing it?