|
|
| GetTickCount() != clock() ??? |
|
LSd016
Member #3,561
May 2003
|
Should there be any differences between these two? When I decided to switch to clock(), for a cross-platform compatibility and stuff, the FPS counter showed up as if the FPS was on a normal level - 87, but the whole game was actually running at 10 FPS or so. #include <winalleg.h> // i uncomment this to use clock() #ifndef GetTickCount inline long GetTickCount(void) { return clock(); } #endif
____________________________________________ |
|
Evert
Member #794
November 2000
|
Quote: Should there be any differences between these two? Yes. msdn said: GetTickCount The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer.
clock()'s man page said:
SYNOPSIS clock_t clock(void); DESCRIPTION
|
|
LSd016
Member #3,561
May 2003
|
microsecond? 1/1000000 second? The libc help I got with djgpp says "ticks", and also, in time.h, i found this: #define CLOCKS_PER_SEC ((clock_t)1000) Wouldn't this mean they're miliseconds? ____________________________________________ |
|
Evert
Member #794
November 2000
|
It depends on the definition of clock_t. The above quoted manpage is for solaris. The Linux manpage says Quote:
DESCRIPTION RETURN VALUE CONFORMING TO However, the most important difference (as quoted in my first post) is Quote: The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started vs. Quote: The clock() function returns the amount of CPU time (in microseconds) used since the first call to clock() in the calling process. It seems that they don't do (exactly) the same thing. EDIT: any particular reason you don't want to use Allegro's timer routines? |
|
CGamesPlay
Member #2,559
July 2002
|
Evert: because they're for a totally different purpose? Really, the timer routines call for a different design than using functions calls.If you're synchronizing somethin, the timer routines may be the way to go, but as for timing something, I'd go against a callback-based approach. -- Ryan Patterson - <http://cgamesplay.com/> |
|
Evert
Member #794
November 2000
|
Quote: If you're synchronizing somethin, the timer routines may be the way to go, but as for timing something, I'd go against a callback-based approach. You can time it by having a counter running in the background and comparing the value of the counter at different times. It's pretty much the same as using clock(), but probably less accurate than a library function that is more low-level. |
|
|