Drawing to FBO outside an openFrameworks draw();

(I’m just full of questions lately)

I made an applications that uses a big ofFbo in order to draw big graphics to later modify its viewing perspective. My guess is the drawing itself uses up a lot of processing and it is all done inside an FBO like follows:

void testApp::draw(){  
// Stuff  
// Big graphics!!!  
// more stuff.  

Now I was told when I started using openFrameworks that I should leave processing inside the update(), but the use of huge FBO drawing inside draw() would make an application run at slower framerate. So I would like to ask:

1.-Is this normal?
2.-Is there a way in which could draw to an FBO without affecting the framerate?.
3.-Should I worry? :stuck_out_tongue:

Thank you :slight_smile:

drawing to an FBO takes just as much GPU time as drawing to the screen. so if you are drawing to an FBO, and also drawing to the screen, you might see your framerate drop to half. there’s no way around that. similarly, if you draw to a large FBO it will take just as much time as drawing to a large screen.

CPU-based things should be inside update(), GPU-based things should be inside draw. assuming double-buffering is working correctly, this will keep your fps as high as possible.

May I ask, is it possible to use multithreaded cores for parallel processing? gpu? cuda? or something to speed up the processing inside openF?

I’ve also never been really sure about what the old ofxThread or the newer threadedObject do. Does it have to do with processing threads that can be sent to different cores?

I’m also confused as to what the opencv2 inside openF can do but I’ve read that OpenCV 2 has a bit or gpu functionality added. This would be great for me. Does openF 007 come with an openCV 2 example of advanced funcionality? Do you know of any good examples with source code? :slight_smile:

:stuck_out_tongue: Too many questions!!! xD

first, a clarification: threadedObject is just an example of using ofxThread, it’s not ‘newer’.

second, to answer your general question, there is no magic code, switch you can turn on, or small modification you can make that will make OF faster. if something like that existed, it would already be inside OF :slight_smile:

you’re asking questions about a very big topic so i’ll try to explain a little of what i know:

your code is always describing an algorithm. the algorithm is executed by a computer. the CPU is one kind of computer, and the GPU is another kind of computer. the CPU is normally attached to and supported by your motherboard, RAM, hard drive, etc. the GPU is attached to and supported by your graphics card.

the CPU will evaluate the algorithm step by step (“serial”). this is good for algorithms where every step depends on the previous step.

the GPU will evaluate as many steps as possible at the same time (“parallel”). this is good for algorithms where the steps don’t depend on each other.

some CPUs are multicore, or “a little parallel, mostly serial”.

sometimes you can translate an algorithm from one domain to the other, and it will be faster. this isn’t always true. when you’re implementing something on the GPU that would normally run on the CPU, this is called “general purpose GPU” (GPGPU). you can write GPGPU code with CUDA, OpenCL, or sometimes with GLSL+FBOs if you’re creative.

OpenCV 2 has some code that supports GPU-based image processing via CUDA. the version of OpenCV 2 that ships with OF does not have the CUDA stuff enabled, because it’s platform-specific, and graphics card-specific (NVIDIA only). if you compiled it yourself, you would be able to use it. there are some posts on the forum about compiling OpenCV 2 with CUDA support. image processing is a good place to use the GPU because the algorithms naturally translate into a “parallel” format.

in practice, the OpenCV 2 GPU stuff only makes some fast things very fast. any slow OpenCV algorithms are probably slow for a good reason, and might not even translate to the GPU very well.

You know Mr. kylemcdonald… I could write a book with all of the replies you’ve given to my questions. Thank you very much for your time.
I guess tomorrow I will start learning GL, GLSL and openCV 2! and if I void the warranty on my GPU I’ll blame you. =D