60 frames per second

Blitz3D Forums/Blitz3D Beginners Area/60 frames per second

Amanda Dearheart(Posted April) [#1]
How can a tell if my program/app is runnning at 60 fps.
For that matter, how can I find out how many frames per second my app is runnning.


xlsior(Posted April) [#2]
Count how many times flip gets invoked every second


Kryzon(Posted April) [#3]
it's the time difference between the current and previous frames in your program, people call this "frame time" and it's usually measured in milliseconds.
While (...)
frameTime = Millisecs() - lastTime
If frameTime = 16 Then Text(0, 0, "Running at 60 FPS")

lastTime = Millisecs()
Wend
If that frame time is close to 16.666 milliseconds then your program is running at approximately 60 frames-per-second.

This 16.666 value comes from the expression (1000.0 / 60.0) "If a second (= a thousand milliseconds) is divided into sixty slices, how many milliseconds are in one of those slices?" and then you check if the latest slice follows this rule.


Midimaster(Posted April) [#4]
To guarantee that your app is running at 60FPS at any computer use CREATETIMER() and WAITTIMER:

FPS%=CreateTimer(60)

; Your mainloop:
While Not KeyHit(1)
      Cls
      ;Draw your screen stuff here
      Flip 0
      WaitTimer FPS
Wend




Amanda Dearheart(Posted April) [#5]
Thanks guys


RemiD(Posted April) [#6]
i use this code to count the frames per second (FPS) :
;before the mainloop :
Global MainLoopTimer = CreateTimer(30) ;this is used to limit the maximum FPS, but not required

;during the mainloop :
Repeat

 MainLoopMilliStart% = MilliSecs() ;the milliseconds value at the start of the mainloop

 UpdateProgram() ;update your program here

 SetBuffer(BackBuffer())
 RenderWorld()

 Color(255,255,255)
 CText("FPS = "+FPS,0,0)
  
 ;Flip(1) ;use only this line if you don't want to limit the FPS
 WaitTimer(MainLoopTimer) ;use this line and the next if you want to limit the FPS
 VWait():Flip(False)

 MainLoopMilliTime = MilliSecs() - MainLoopMilliStart ;the milliseconds time it takes to do a mainloop
 If( MainLoopMilliTime < 1 ) ;this is to prevent a division by 0 when calculating the FPS
  MainLoopMilliTime = 1
 EndIf

 FPS% = 1000.0/MainLoopMilliTime

until( keydown(1)=true )



gpete(Posted April) [#7]
I think if you use Win 10- 60 FPS is the most Blitz can do while rendering and updating the screen- my progs all run at 60 FPS.
Some commercial games on my pc claim to run at 70+ fps but I doubt it.
Or is it because monitors run at 60 fps? hmmmm....


Amanda Dearheart(Posted April) [#8]
RemiD, thanks!!