It is currently Thu May 28, 2020 4:23 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [LIB] GameTimer: FPS / Frametime / Deltatime [Windows x64]
PostPosted: Sat Feb 15, 2020 6:41 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 648
I coded a small timer library in fasm to calulate the FPS, Frametime an Deltatime.
If your application or game does not have VSynce the library will take care of the timing without stressing the cpu.

Maybe someone wants to help me develop this further :)

PureBasic Example (PB 5.62 x64):
Code:
EnableExplicit

;gametimer.lib / fasm / x64 / os: windows
;(c)2020 by mijikai

Import "gametimer.lib"
  GameTimerInterface.i()
  GameTimerVersion.i()
EndImport

#GAMETIMER_VERSION = $0001

Interface GAMETIMER
  Start.i()
  Stop.i()
  Time.d()
  Delay.i(Milliseconds.i)
  WaitForMS.i(Milliseconds.i,VSync.i = #False)
  WaitForFPS.i(FPS.i,VSync.i = #False)
  Wait.i()
  WaitTime.d()
  WaitDelta.d()
  WaitFPS.i()
  Resolution.i()
  Release.i()
EndInterface

Global *gametimer.GAMETIMER

If GameTimerVersion() = #GAMETIMER_VERSION
  *gametimer = GameTimerInterface()
  If *gametimer
    *gametimer\Start()
    *gametimer\Delay(100)
    *gametimer\Stop()
    Debug *gametimer\Time();<- time will return the time elapsed (start -> stop) on 100 ns units!
    Debug ""
    *gametimer\WaitForFPS(60)
    *gametimer\Wait()
    Debug *gametimer\WaitTime()
    Debug *gametimer\WaitDelta()
    ;*gametimer\WaitFPS() <- game needs to run for atleast one second to calculate fps!
    Debug ""
    *gametimer\WaitForFPS(60,#True);<- if the game has vsync set the vsync flag to #True!
    *gametimer\Delay(16);<- simulated vsync!
    *gametimer\Wait()
    Debug *gametimer\WaitTime()
    Debug *gametimer\WaitDelta()
    Debug ""
    Debug *gametimer\Resolution();<- resolution of the internal delay in 100 ns units!
    *gametimer\Release();<- cean up everthing
  EndIf
EndIf

End


Download: https://www.dropbox.com/s/hhr753b2gyw3rhc/fasm_gametimer_x64_v.1.0.zip?dl=0


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye