How does OnRender get called?
Monkey Forums/Monkey Programming/How does OnRender get called?
| ||
Hello all, I have a question that I'm not sure I fully understand. When we use the SetUpdateRate command to cause the "OnUpdate" and "OnRender" functions to be called regularly - at what point in program execution are they called? I am more used to programs that seem to flow in a straight line - line by line executing each statement, but I don't understand how OnUpdate gets called - or more importantly:when? Will OnUpdate/OnRender get called in the middle of another method or function, or does it wait until all other commands have finished executing? |
| ||
If you look in the native implementations for mojo you can see for yourself. Roughly speaking and just based on my brief scanning of the HTML5 code: * OnCreate gets called and then OnRender * Then there's a timer running to trigger at the update rate. This calls OnUpdate and then OnRender. * If the OnUpdate call takes longer than the update period then it keeps calling OnUpdate alone to try and catch up. There's a break clause after a number of loops so that it occasionally manages to render a frame if your update is consistently too slow. The implementation is single-threaded, so no, there will be no surprise calls to OnRender or OnUpdate while you're still processing the last one. |
| ||
Thanks muddy_shoes...makes sense, and good to know. |