0 Members and 1 Guest are viewing this topic.
'----------------------' FPS Limiter'----------------------' by Rbraz - 2006'----------------------Option Explicit' Includes#Include Once "windows.bi"'Sub RoutinesDeclare Sub FPS_Count()'FPS CounterDim Shared iFPS, bSettime,iSecStart,iFrameCount,iFrameStart as integer'--------------------------------------------------Const MAX_FPS = 60 'Max FPS DesiredDim Freq as LARGE_INTEGERDim cTimer1 as LARGE_INTEGERDim cTimer2 as LARGE_INTEGERDim Interval as double'-------------------------------------------------- QueryPerformanceFrequency(@Freq) 'Get Frequency Interval = CDBL(Freq.QuadPart) / CDBL(MAX_FPS) 'Calculate interval based on MAX_FPS and Frequency'Main LoopWhile Inkey$() <> Chr$( 27 ) QueryPerformanceCounter(@cTimer2) if(cTimer2.QuadPart >= cTimer1.QuadPart + Interval) then QueryPerformanceCounter(@cTimer1) locate 8,30 print "Desired FPS: " & MAX_FPS locate 10,30 print "Current FPS: " & iFPS FPS_Count() end if Wend'End MainSub FPS_Count() If bSettime = 1 then iSecStart = Timer() * 1000.0 iFrameStart = iFrameCount bSettime = 0 EndIf If (Timer()*1000.0) >= iSecStart + 1000 then iFPS = iFrameCount - iFrameStart bSettime = 1 EndIf iFrameCount = iFrameCount + 1 End Sub
5H0CKW4VEI may well pinch this, will credit you of course.. Thanks Rbraz