Oh I just checked your sources and found out you are doing some timing with QPC.... I didnt check if you get the frame time with QPC too, but if so, this might be the problem.
QPC is known to be buggy in many ways:
- If you have more then one CPU core the frequency might change depending on the core your thread is running on.
- The frequency can be dynamic if you are running this on a CPU that changes it's speed (for energy saving purposes, e.g Laptops and some low energy using desktop CPUs)
- some CPUs have dynamic clock skip feature used for thermal throttling
- If you are using it in virutalized environment, e.g. VMWare, Xen, VirtualBox etc you will get most likely not get real values.
...
Well, therefore most programmes do this:
check if the frequency from QPC is "stable" over time and if it fits to the values returned from getTickCount. If not, consider it as bugged and use getTickCount or timeGetTime().
Another way would be a nice callback timer....this one calls a function to increase a counter....:
// Some variables to put somewhere:
MMRESULT timer_id = 0;
TIMECAPS timer_caps;
unsigned int volatile GlobalInternalTimerValue = 0;
// Timer init:
if( timeGetDevCaps(&timer_caps,sizeof(TIMECAPS)) != TIMERR_NOERROR)
return Error("Unable to retrieve timing capabilities");
if( timeBeginPeriod(timer_caps.wPeriodMin) != TIMERR_NOERROR )
return Error("Unable to set timer resolution" );
timer_id = timeSetEvent(1,timer_caps.wPeriodMin,timer_func,0,TIME_PERIODIC);
if( timer_id == 0 )
return Error("Unable to create timer");
// Timer callback:
void CALLBACK timer_func(unsigned int,unsigned int,DWORD,DWORD,DWORD)
{
GlobalInternalTimerValue++;
}
// Timer release:
unsigned int hr = timeEndPeriod( timer_caps.wPeriodMin );
// make sure hr == TIMERR_NOERROR
hr = timeKillEvent( timer_id );
// make sure hr == TIMERR_NOERROR