// Author : Chris Tolley
// Datet  : 6/22/2004
// HiResTimer.cpp contains the class definition for a high resolution timer.
// This only works if the computer it is running on has a high resolution timer

#pragma warning ( disable : 4800 )

#include "HiResTimer.h"


// Default Constructor
HiResTimer::HiResTimer()
{
}


// Destructor
HiResTimer::~HiResTimer()
{}


// Initializes the timer.
void HiResTimer::Initialize()
{
	QueryPerformanceFrequency( &m_liFrequency );
	QueryPerformanceCounter( &m_liLastTime );
}// End HiResTimer::Initialize


// Returns true if the computer supports this timer
bool HiResTimer::isSupported() const
{
	LARGE_INTEGER n;
	return QueryPerformanceCounter( &n );
}// End HiResTimer::isSupported


// Returns the number of seconds that have elapsed since the last time
// this function was calls
float HiResTimer::getElapsedSeconds()
{
	LARGE_INTEGER currTime;
	QueryPerformanceCounter( &currTime );

	// Calculate the number of seconds that have elapsed
	float seconds = 
		( float( currTime.QuadPart ) - float( m_liLastTime.QuadPart ) ) /
									m_liFrequency.QuadPart;

	// Set the last time to the current time
	m_liLastTime = currTime;

	return seconds;
}// End HiResTimer::getElapsedSeconds
