Advertisement

frame rates

Started by December 08, 1999 05:16 PM
4 comments, last by destroid 24 years, 11 months ago
Well, I use timeGetTime to determine the fps and I have heard that alot of other ppl use it to. So I include a snippet of a fps counter

#include
#include // timeGetTime() is in this on

// ...

static DWORD flNewElapsedTime;
static DWORD flOldElapsedTime = 1;
static int flFrameRate = 0;


// In the main game loop (before the render/calc/AI):

flNewElapsedTime = timeGetTime();

// and when all the stuff is done:

flFrameRate = (int)(1000/(flNewElapsedTime - flOldElapsedTime));
flOldElapsedTime = flNewElapsedTime;
flNewElapsedTime = timeGetTime();

// And there it is

Death is lifes way saying your fired.
You could also use the Performance timer. Which to me, seems more to be a more accurate timer.

QueryPerformanceCounter and QueryPerformanceFrequency should be the only two functions you need.

Advertisement
This has probably been covered before but I couldn't find any previous posts on it..

how to determine the fps in a directX app. do you just have a static counter in your game loop and use windows' timer functions to determine when a second passes, then show the value and reset it to zero? are windows' timer functions very accurate? or how could you accomplish this using GetTickCount() ?

Thanks

------------------

"can't waste the day when the night brings a hearse"


"can't waste the day when the night brings a hearse"
why did you repeat the line..
flNewElapsedTime = timeGetTime(); ??

Do I have to include any .lib files for it to work?

error LNK2001: unresolved external symbol __imp__timeGetTime@0
Debug/blabla.exe : fatal error LNK1120: 1 unresolved externals
When you see link errors like this, just do a search in the online help for the function to see what import lib you need. In this case, you''ll find (amoungst other things)


Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in mmsystem.h.
Import Library: Use winmm.lib.


Thanks,


Notwen
Notwenwww.xbox.com

This topic is closed to new replies.

Advertisement