Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This is the text and function detailed in a book I'm reading;

 

This function uses the system.environment.tickcount to retrieve the current tick of the processor clock (with the precision rate of a millisecond), so we can calculate the frame rate. Note this functionis not very accurate, but since we only use frame rate calculations to give us an idea of the speed at which we're drawing the scene, and won't include it in our final games, we think using it is a valid approach


Public Function CalcFrameRate() As Integer

 Static FrameRate As Integer
 Static LastFrameRate As Integer

 Dim LastTick As Integer

 If System.Environment.TickCount - LastTick >= 1000 Then

   LastFrameRate = FrameRate
   FrameRate = 0
   LastTick = System.Environmetn.TickCount

 End If

 FrameRate += 1
 
 CalcFrameRate = LastFrameRate

End Function

 

In plain English, why is this not accurate?

 

Thnx

My website

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...