• Create Account

### #ActualHodgman

Posted 17 November 2012 - 10:51 PM

You shouldn't be calling timeGetTime twice per frame like that -- the result of that code is that you're not timing your Draw/Update code at all, you're only timing the code that comes between the bottom line and the top line.
You can change it to only call timeGetTime once per frame like this:
static DWORD lastFrameTime = 0;
DWORD frameDelta;
DWORD thisFrameTime = timeGetTime();
if( lastFrameTime == 0 )//first frame!
frameDelta = 0;
else
frameDelta = thisFrameTime - lastFrameTime;
lastFrameTime = thisFrameTime;
//DoStuff

P.S. timeGetTime isn't very accurate, so most people use QueryPerformanceCounter/QueryPerformanceFrequency instead, or you can use someone else's ready-made high accuracy timer, such as timer_lib.

### #1Hodgman

Posted 17 November 2012 - 10:49 PM

You shouldn't be calling timeGetTime twice per frame like that -- the result of that code is that you're not timing your Draw/Update code at all, you're only timing the code that comes between the bottom line and the top line.
You can change it to only call timeGetTime once per frame like this:
static DWORD lastFrameTime;
static DWORD frameDelta;
DWORD thisFrameTime = timeGetTime();
frameDelta = thisFrameTime - lastFrameTime;
lastFrameTime = thisFrameTime;
//DoStuff

P.S. timeGetTime isn't very accurate, so most people use QueryPerformanceCounter/QueryPerformanceFrequency instead, or you can use someone else's ready-made high accuracy timer, such as timer_lib.

PARTNERS