Refreshing graphics with paint()?


#1

Hi, I’m working on a swarm intelligence algorithm in Juce, and am refreshing all my graphics positions in paint() but notice it’s lagging and not refreshing properly. I’m wondering if I’m correct in thinking of refreshing my graphics in the same way I’d think of void draw() in openFrameworks, or do I have this wrong?

Thanks for any help.


#2

You probably want to do all of your calculations in a separate thread, and just do the drawing in paint().


#3

If you’re after an openframeworks-style continuous repaint behaviour then maybe the AnimatedAppComponent class would do what you expect?


#4

The AnimatedAppComponent class did the trick. Thanks!


#5

Good, but you should learn about how paint/repaint works, because that’s the mechanism that pretty much every GUI system on every OS actually uses underneath.


#6

Thank you for the advice, I’ll have a look into it!