Jump to content
  • Advertisement
Sign in to follow this  
mike74

frame rate measurement

This topic is 4868 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

I'm writing a maze game, and I'd like an easy way to compare its frame rate to that of Unreal. Unfortunately, the "fraps" utility doesn't work on my PC - it says I need a processor that supports "SSE" instructions. Does anyone know of any good alternatives to fraps? I've looked, and so far, nothing's turned up. Mike C. http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Advertisement
Here's what I do (programming in Windows, Dev-C++):
//Global Variables:
ULONG FRAME_START;
float FPS; //It can have floating-point frame-rates
//Beginning of the frame
FRAME_START=GetTickCount(); //This time is measured in milliseconds
...
//End of the frame
if (FRAME_START!=GetTickCount()) FPS=(float)1000/(GetTickCount()-FRAME_START);

And if you want to control your frame rate, use a while loop with a condition that checks if a certain amount of time has passed since FRAME_START.

Share this post


Link to post
Share on other sites
Be warned:
For most projects it may not matter, but GetTickCount isn't especially accurate. It's (I believe) preferred to use QueryPerformanceCounter. But once again, it may not matter if it's 10ms off for your project. It probably doesn't.

Good luck.

Share this post


Link to post
Share on other sites
Here is a function that I call each frame to calculate FPS (updates every second) and calculates the elapsed time from previous frame to current frame which I use for movement calculations. You will have to alter it to fit your project.


void CBApp::CalculateFrameTime() {
mFrameCount++;
DWORD time = timeGetTime();
if ((time-1000)>mBeginTime) {
mFPS=mFrameCount;
mFrameCount=0;
mBeginTime+=1000;
}
mElapsedTime = time - mLastFrameTime;
mLastFrameTime = time;
}


Edit: To ensure you get 1ms accuracy with timeGetTime, you need to put this at the beginning of your program:

timeBeginPeriod(1);

and this at the end:

timeEndPeriod(1);

I believe you also have to link to winmm.

Share this post


Link to post
Share on other sites
ricekrispyw >> I never knew about QueryPerformanceCounter... What's the scale for this? Milliseconds (1/1000 second), Nanosecond (1/? second)? How would I implement this in a similar form as my code above?

Share this post


Link to post
Share on other sites
Interesting. Is there a way to measure Unreal's frame rate though?


Mike C.
http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!