update() vs draw()

Can somebody tell me what exactly is the difference between the update() and the draw() functions? I assume they are similar functions that get executed in separate callbacks and that the draw() function is for graphics and the update() is for non-graphics (duh), but is there somewhere I can find more detailed information? For example, what is their updating rates, and what order of execution are they? Sequential, asynchronous?

How do I change their rates? ofSetFrameRate(int targetRate) I would think sets the draw() framerate, but is this the same for the update() function as well?

And another newbie question, why have separate update and draw functions? Is it an optimization question?

Thanks!

update and draw are synchronous, and the order they would get called is:

update()
draw()
update()
draw()

if you set the frame rate slower, update will get called slower too since they are synchronous…

the main reason for this is cleaner code, since you can do non-visual stuff in the update (ie, computer vision, update an animation, alter variables, etc) and keep the draw routine purely drawing. Also, I have found it helpful for pinpointing problems, since you can easily comment out draw, or comment out update to get a sense of where bugs are occurring.

we personally like having them separated, but you can do nothing in your update and do everything in your draw if you want…

hope that helps!
zach

yeah, makes perfect sense.