CPU and drawing simple shapes ::: why so much ? ... and smooth fonts

Hi all OF lovers,

I have been working for a few years now with OF. It is really great, and we almost are able to do anything with it…

But i have two main problems with OF that i can not solve, and perhaps there is a good/simple solution.

The first is that drawing, say approx. 100 shapes (rectangles for example) makes the CPU (in my macbook pro from 2006) go to 70%. Using other apps, i can manipulate video, text, sound, etc. making intensive effects, having only around 50% of consumption. This difference is really huge. Only drawing a few shapes seems more intensive than extremely complicated loops, video rendering, math, sound, etc.
In my OF projects I have to use fbos, and only update them when a shape changes…

does anybody has the same problem?
is it because of my computer?
is it a “normal” problem?
any tricks to avoid that ?

The other problem is that fonts and shapes do not display in a smooth and antialiased way. I know all the workarounds that were pointed here (i think so), but none of them worked completely. With other programs (processng, etc.) i get perfect smoothness from the beginning.
This is really annoying, and if somebody has any suggestion about it, please tell me.

best,

miguel.
www.tangiblex.net

To get smoothness in your app,
Without an fbo
have you tried using window.setGlutDisplayString(“rgb double depth alpha samples>=4”);

with an fbo, have you tried upping the fbo samples to something like 4?

Hi Nick,
thanks for the replay.
Yes, i tried (in some projects) the code you show, and it works for some drawings. Still small fonts are not great when rotated, etc.
Also the problem with that code is that t depends on the gpu. Also for windows, it must be different and issues can come…

The second question you make, nop, i did not do that (as far as i remember, cause i tried so many things…). I will give it a try. Thanks.

Any idea about the huge cpu load, or other solutions to smooth?

Not sure about the cpu load, it could depend on the code used to render the shapes.
I tried this draw code in an empty example drawing 1000 rects and am using < 5% cpu on my MacBook Pro 2.6 GHz Intel Core i7.

  
for(int i = 0; i < 1000; i++ ) {  
        ofSetColor(ofRandom(0,255), 255, ofRandom(0, 255));  
        ofRect(ofRandom(0,ofGetWidth()), ofRandom(0, ofGetHeight()), ofRandom(10, 30), ofRandom(10, 30));  
    }  

I think the small font might be difficult if you are rotating. Have you seen the examples/graphics/fontsExample?

Processing also uses anti-aliasing, it is on by default, explained here: http://processing.org/reference/smooth-.html

Which is the same as setting the GLUT display string or setting the anti-aliasing on an fbo.
Have you tried ofEnableAntiAliasing()?

Setting the GLUT display string should work on windows, read the last post here:
http://forum.openframeworks.cc/t/anti-aliasing-not-working-on-windows/5968/0

Ouoau,
thanks for the good replay. I will test all of that and come back with results .

thanks again.

actually antialiasing is now enabled by default so using the glut string won’t have any effect.

also the antialiasing for fonts and shapes happens in different places. for fonts the antialiasing that you could enable with the glut string and is now enabled by default, won’t have any effect since fonts are drawed as bitmaps.

it seems like there are fonts that work better than others with the library we use for rendering fonts (freetype). for example the default helvetica in osx doesn’t work very well with small sizes.

also posting an image of the results you get in OF and processing would help.

It sounds like simply you run the app extremely fast. Did you set the frame rate? (It might be too obvious though.)