updaterate 0
Monkey Targets Forums/Desktop/updaterate 0
| ||
Hi, I have a question: When I use updaterate 0 on the desktop target my game will update as often as it can. Will that also mean that rendering is done as often as possible? It seems that update and render are linked. |
| ||
I answered this question myself by making a little test:Import mojo Function Main:Int() New mygame End Function Class mygame Extends App Field renderticks:Int Field updateTicks:Int Method OnCreate() SetUpdateRate(0) End Method Method OnUpdate() updateTicks += 18 End Method Method OnRender() renderticks += 1 DrawText("update: " + updateTicks + ", renders: " + renderticks, 0, 0) End Method End Class Render calls are done as often as possible as well. Has anyone here successfully de-coupled update and render calls in Monkey? This is for the desktop target only. |
| ||
This thread is turning in to a self fulfilling prophecy or something :) I just found out about the SetSwapInterval(1) additions, etc.... Adding that command to the OnCreate() method achieves what I am after, in a way. Vsync will force a 60 fps on a monitor running at that frequency. There is, I guess, not a way to fully control how and when OnRender() is called. I just realised I can work with a timer in the OnRender() method and control things from there. Is this a good idea or will I be breaking something?? Any ideas? Or am I trying too hard and is the default way of mojo (what is that, anyway?? Is there a post somewhere here which explains how the timing etc is done?) 'good enough' ?? |
| ||
Yes, SetUpdateRate(0) will make sure that after each OnUpdate there will be a call to OnRender. |
| ||
Now why would there be a call to OnRender after each OnUpdate? I could've sworn that UpdateRate 0 decouples them both. That would mean you gotta delta-time everything, at least I thought..... If they're tied to each other, how does the game stop runaway conditions? It's gotta drop frames sometime.... |
| ||
The docs say this: Function SetUpdateRate : Void ( hertz:Int ) Sets the application's update rate. If hertz is non-zero, this is the number of times per second that the application's OnUpdate method should be called. Commonly used update rates are 60, 30, 20, 15, 12 or 10 updates per second. OnRender is also called at the same frequency if possible (after each OnUpdate), meaning SetUpdateRate effectively also sets the target frames per second. So I think for a desktop app to behave like I want it to ( fixed (60) logic updates per second, render as often as possible) is to go with this: - SetUpdateRate(0) - Use a fixed timer in the OnUpdate() method - Render as often as possible using interpolated values for positions. |