Accurate FPS
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.
Thanks
phate
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.

Thanks
phate
http://www.mactech.com/articles/develop/...minow.html
Code:
UnsignedWide startTime;
UnsignedWide endTime;
Microseconds(&startTime);
DoMyOperation();
Microseconds(&endTime);
Cocoa
POSIX
Carbon
Are generally the easiest ways to get accurate timings. All appear to be accurate to below the microsecond.
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.
I have exactly what you want...
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.
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Creating Stable And Accurate Physics With Newton | Nick | 0 | 1,896 |
Oct 19, 2006 04:56 AM Last Post: Nick |
|

