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;
}
a set FPS
Hey guys:
I have this code:
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
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
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
its in milliseconds, so don't I need to divide 1000 milliseconds/ fps? to get how many milliseconds per frame
ok, with this:
I'm getting 16 frames per second... any clues??
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??
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?
Just out of curiosity, why do you want to limit the framerate to 12?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement