About Monkey 2 › Forums › Monkey 2 Programming Help › How to get constant high FPS?
This topic contains 2 replies, has 3 voices, and was last updated by
Gwenel
1 year ago.
-
AuthorPosts
-
March 6, 2018 at 3:52 pm #13893
I’ve tried to increase the fixed FPS to 1000 using a timer and SawpInterval=0 and my computer is stuck at 93 though the timer is actually going at 1000! Without the use of a timer it caps at +-4500. Is it possible to fix a higher constant fps somehow? Would this limitaion also happen with high hz vsync screens like 144hz screens?
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField t:TimerField t2:TimerField count:=0Field initialMillisecs:IntMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )SwapInterval=0t2=New Timer(1000,UpdateCount2) 'comment this line to see max FPSinitialMillisecs=Millisecs()EndMethod OnRender( canvas:Canvas ) Override'App.RequestRender() 'uncomment this line to see max FPSLocal dt:=Millisecs()-initialMillisecscanvas.DrawText( "Hello FPS: "+App.FPS+" -- "+dt+" --- "+count,Width/2,Height/2,.5,.5 )EndMethod UpdateCount2()count+=1App.RequestRender()EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndMarch 6, 2018 at 10:31 pm #13895I’m not sure if there’s a built in way to do this, and timers might be constrained to some unseen minimum delay problem. Not sure if that’s the case.
A possibility would be to handle this yourself. If you know that a framerate is possible at a certain level, you could fix it there. This would be something like having some sort of “rest” loop which will attempt to imitate that work is being done to throttle the framerate.
psuedo logic:
while( timeTilNextDesiredTick > CurrentTime ){
‘wait here (this is very crude)
}There are more details about sequencing framerate here: http://gameprogrammingpatterns.com/game-loop.html#how-do-you-control-gameplay-speed
April 13, 2018 at 11:09 am #14344Following
-
AuthorPosts
You must be logged in to reply to this topic.