PDA

View Full Version : help with frames per second



mdog1234
12-06-2002, 10:59 AM
I am having trouble calculating my frames per second. I have a function that computes it but I know its wrong because its always less than 1 and there is no way thats right because I can move my object around and it doesnt even flicker.

here is my function what am I doing wrong

void calc_fps()
{
char fps[20] = {0};
float time,cur_time;
float total;
static float prev_time = 0.0;


time=glutGet(GLUT_ELAPSED_TIME);

cur_time=time-prev_time;

prev_time=time;

total = cur_time/1000.0;sprintf(fps,"FPS:%f", total);


}

GameMaker
12-06-2002, 02:28 PM
I think your function will calculate seconds per frame instead of frames per second. I think you need to take 60.0f and divide by your calculation.