Archived

This topic is now archived and is closed to further replies.

AbsentMinded

question on my timer code...

Recommended Posts

Ok i know there are some other posts about this type of stuff i just want to know why my code isnt working because it looks to me like it should yet it just shows me getting like a max of 72fps when i should be getting alot more since im not doing anything just making the window lol here is my class im using...all im using it for so far is to get the fps...
class Ctimer
{
	__int64 _startTime;
	__int64 _frequency;

	short	_fps;
	short	_frames;

public:
	Ctimer() {}
	~Ctimer() {}

	void init();
	void update();

	inline short getFPS() { return _fps; }
};

void Ctimer::init()
{
	QueryPerformanceFrequency((LARGE_INTEGER*)&_frequency);
	QueryPerformanceCounter((LARGE_INTEGER*)&_startTime);
}

void Ctimer::update()
{
	_frames++;

	static __int64 lastTime =_startTime;
	LARGE_INTEGER currTime;
	QueryPerformanceCounter(&currTime);

	if(currTime.QuadPart-lastTime >= _frequency)
	{
		_fps=_frames;
		_frames=0;
		lastTime = currTime.QuadPart;
	}
}

[edited by - AbsentMinded on July 26, 2003 8:00:20 AM]

Share this post


Link to post
Share on other sites