On the "openFrameworks for Processing users" tutorial

Hi there,

Under the section “PImage, updatePixels() vs. ofTexture, pixels[]” the method suggested for keeping the objects drawn on the screen is to us grabScreen. That seemed odd so I tried it and the output was an image with a lot of unwanted artifacts. Later I realized that this is also the method suggested in Joshua Noble’s “Programming interactivity: A guide for Processing, Arduino, and OpenFrameworks.”

Wouldn’t using a frame buffer object be better? Is there a technical reason for using grabScreen?

First, this tutorial was last updated in 2008, so it may be wise to be extra careful with it’s suggestions. Things may have changed in the meantime and the information could be outdated.

Second, I don’t see anywhere in the article that “the method suggested for keeping the objects drawn on the screen is to use grabScreen”. The article just states that an ofImage can be used for EITHER a loaded image OR an image grabbed from the screen. In BOTH cases the way that the image is drawn to the screen is via ofImage’s draw method.

Which is the better instrument, depends on what you are trying to accomplish. If you want to draw objects to an offscreen buffer than indeed ofFbo may be a better option (the equivalent of PGraphics in Processing).

Thanks for the reply.

Well, modify means to keep some and change some, instead of creating a brand new one and replace the old one. At least this is how I interpreted it. But you are right, it was badly paraphrased.

I will try to ask it in a more clear way. Suppose in my application I need to change only a small part of what is on the screen at each refresh. Say, I want to program a brush which only makes local modifications. Two methods come to my mind. First: keep a copy of the screen in a frame buffer, modify the buffer at each update and draw the buffer. Second: use grabScreen(). The first one seems more natural to me and the second one produces unwanted glitches.

From your description, is does indeed sound like using an ofFbo is the cleaner/better option. The benefit of using an ofFbo as a canvas in a drawing program is for example that you can easily display the brush on top of the canvas, but only affect the canvas (aka the ofFbo) when the mouse is pressed by the user. Indeed, the logic of such a route is more natural.