Accurate FPS

Phate
Unregistered
 
Post: #1
I'd like my animations and movement to be based on the FPS of the game, now the frames per second should be "1/(microsecondsSinceLastFrame*1000000)" (right?).

But one question, how do I get the microseconds so I can use them to say "microsecondsSinceLastFrame = microNow - microLastFrame"?

I tried just typing Microseconds(), but it appears to want an "UnsignedWide" and I don't know what that is exactly. Sad

Thanks
phate
Quote this message in a reply
Patrick
Unregistered
 
Post: #2
http://www.mactech.com/articles/develop/...minow.html

Code:
UnsignedWide    startTime;
UnsignedWide    endTime;

Microseconds(&startTime);
DoMyOperation();
Microseconds(&endTime);
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
Cocoa
Code:
+[NSDate timeIntervalSinceReferenceDate]

POSIX
Code:
gettimeofday()

Carbon
Code:
GetCurrentEventTime()

Are generally the easiest ways to get accurate timings. All appear to be accurate to below the microsecond.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
I have exactly what you want...

Code:
#include <CoreServices/CoreServices.h>

double GetUpTime(void)
{
    AbsoluteTime atime = UpTime();
    Nanoseconds nsecs = AbsoluteToNanoseconds(atime);
    double     time = UnsignedWideToUInt64(nsecs);
    return time*1.0E-9;
};


This function returns the uptime of the machine in seconds, and on my machine (G4/400) two successive calls measure a delay of 1.3-1.4 microseconds.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Creating Stable And Accurate Physics With Newton Nick 0 2,000 Oct 19, 2006 04:56 AM
Last Post: Nick