in the tutorials i see them teaching to use a "preformance timer" which seems quite complicated to the new programmer. If you read up on the
clock() function you will find that it is quite simple, and it calls on any platform.
Basically what the
clock() function does is return the time your program has been running.
this is what MSDN says about it:
------------>8-------------------
The clock function's era begins (with a value of 0) when the C program starts to execute. It returns times measured in 1/CLOCKS_PER_SEC (which equals 1/1000 for Microsoft C).
------------8<-------------------
I looked it up on my linux machine and CLOCKS_PER_SEC is equal to 1,000,000
either way, this is pretty damn accurate

i added a very accurate FPS to my program with only a few lines of code... no confusing structs, no confusing init routines...
#include <time.h>
long getFPS(){
static long frameCount = 0;
static long totalFrames = 0;
static unsigned long lastTime = 0;
unsigned long curr = clock();
if(curr - lastTime >= CLOCKS_PER_SEC){
totalFrames = frameCount;
frameCount = 0;
lastTime = curr;
}else
++frameCount;
return totalFrames;
}
in my scene redering function, i just call
getFPS() and thats it.. no other magic tricks.
Im not saying that the tutorials are wrong at all, i am only pointing out another, more simpler way to set a very accurate timer.
-andy
[edited by - SonicMouse2 on May 10, 2002 11:11:34 AM]