Unhooking Update from Render?

Monkey Forums/Monkey Programming/Unhooking Update from Render?

Chroma(Posted 2011) [#1]
I noticed that when you specify a SetUpdateRate 60 that it also renders at 60 frames per second too. How do we separate logic from rendering?


Rixarn(Posted 2011) [#2]
Well, you can try doing a loop inside the OnUpdate to do more Updates than Renders... aside from that... i can't think of a way of doing that.


c.k.(Posted 2011) [#3]
Can you just do SetUpdateRate 1000? Then it will update and render as fast as it possibly can.


muddy_shoes(Posted 2011) [#4]
All you can do (without altering the mojo code) is set the update rate to some multiple of your desired update and render rate and then perform your own checks to limit the actual updates/renders you do.

The Monkey Box2D demo does this so that the render rate is at 30fps and the update rate is at 60fps (within the limits of the actual platform performance, that is). See:

http://code.google.com/p/monkeybox2d/source/browse/demo/maindemo.monkey

Note that if your update ends up slower than your requested frame-rate the mojo implementation will skip OnRender calls so the frame-rate that the user sees will fall off a cliff.


Rixarn(Posted 2011) [#5]

Note that if your update ends up slower than your requested frame-rate the mojo implementation will skip OnRender calls so the frame-rate that the user sees will fall off a cliff.



Can this be the cause that i'm having 7 update calls for each render? I'm discussing this in another post (about making a loading image for the game)... and if i load just one (rather big) image in the update method, the render method is called once every 7 updates...


muddy_shoes(Posted 2011) [#6]
Yes, that is probably the cause. The mojo update timer will repeatedly call OnUpdate seven times for each frame if the processing is consistently longer than the update rate requested.


Rixarn(Posted 2011) [#7]
So that's the reason... thanks for the explanation :) Then i'll update the other post.