Advertisement

Help: calculate framerate!

Started by February 12, 2005 06:49 PM
2 comments, last by Zuck 20 years ago
Hi, sorry but this is my first post... :P Now, how i can calculate the framerate of my scene? What do you think about this routine?
CTime::ScanFramerate()
{
	TmCurrentTime=clock();

	TmFrames++;

	if (((TmCurrentTime-TmLastTime)*TmFrames)>=(1*CLOCKS_PER_SEC))
	{
		TmFramerate=TmFrames;

		TmFrames=0;
	}

	TmLastTime=TmCurrentTime;

	return 0;
}
I think it works but i don't know if it works really good or not...So i wait an answer... :) Tnx, bye! [Edited by - Zuck on February 13, 2005 6:11:23 AM]
Uhm...Probabily this code is better than last one:

CTime::ScanFramerate(){	TmCurrentTime=clock();	TmFrames++;	TmAcuDelay=TmAcuDelay+(TmCurrentTime-TmLastTime);	if (TmAcuDelay>=(1*CLOCKS_PER_SEC))	{		TmFramerate=TmFrames;		TmFrames=0;		TmAcuDelay=0;	}        TmLastTime=TmCurrentTime;	return 0;}


Results are very different...With only a texturized sprite in a black screen, in the first case the framerate is about 100FPS and in the second one is about 500FPS...What is the right one?
Advertisement
um the second one, the first one asumes that all frames takes the same time, witch they don't.
Ok, tnx :)

[Edited by - Zuck on February 18, 2005 9:01:44 AM]

This topic is closed to new replies.

Advertisement