Sign in to follow this  

a set FPS

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys: I have this code:
currTime = GetTickCount();
	if (currTime >= lastTime + MIN_FRAME_TIME)
	{
		numFrames++;
		if (numFrames > 11)
		{
			float currentUpdate = currTime;
			fps = numFrames / ((currentUpdate - lastUpdate)/1000);
			lastUpdate = currentUpdate;
			numFrames = 0;	
		}
		lastTime = currTime;
	}

I'm trying to get the frames per seconds maintained at 12. my MIN_FRAME_TIME is (1000/12). However, when I calculate the FPS, its averaging around 8fps, 7.994 or something. Any ideas? Thanks!! Jeff King

Share this post


Link to post
Share on other sites
frame/sec*sec=frame
I'm not so sure but you should have multipied not divide

currentTime=GetTickCount()*0.001f;//value in sec

if(currentTime-lastTime>1/NUMBER_OF_FRAMES_PER_SEC)
{

lastTime=currentTime;
...do smth.....

}

EDIT: This should work fine

Share this post


Link to post
Share on other sites
ok, with this:


currTime=GetTickCount()*0.001f;//value in sec
if(currTime-lastTime>1/12)
{
numFrames++;
if (numFrames > 11)
{
float currentUpdate = currTime;
fps = numFrames / ((currentUpdate - lastUpdate));
lastUpdate = currentUpdate;
numFrames = 0;
}
lastTime=currTime;
}



I'm getting 16 frames per second... any clues??

Share this post


Link to post
Share on other sites
What is the resolution of GetTickCount? If it only gives the time every 5 ms or so, after 10 ms (2 ticks), it would be to early so it would wait until the next tick, which would be too late.

Just out of curiosity, why do you want to limit the framerate to 12?

Share this post


Link to post
Share on other sites

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this