Unhooking Update from Render?
Monkey Forums/Monkey Programming/Unhooking Update from Render?
| ||
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? |
| ||
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. |
| ||
Can you just do SetUpdateRate 1000? Then it will update and render as fast as it possibly can. |
| ||
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. |
| ||
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... |
| ||
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. |
| ||
So that's the reason... thanks for the explanation :) Then i'll update the other post. |