This file contains the class FPS that contains two function for calculation of the frame rate.

#ifndef FPS_HPP__INCLUDED
#define FPS_HPP__INCLUDED
 
#pragma once
 
class FPS
{
	unsigned int m_frame;
	unsigned int m_fps;
	sf::Clock m_clock;
 
public:
	FPS() : m_frame(0), m_fps(0) {}
 
public:
	void Update();
	const unsigned int GetFPS() const { return m_fps; }
};
 
void FPS::Update()
{
	if (m_clock.GetElapsedTime() >= 1.f)
	{
		m_fps = m_frame;
		m_frame = 0;
		m_clock.Reset();
	}
 
	++m_frame;
}
 
#endif // FPS_HPP__INCLUDED
 
en/sources/fps.txt · Last modified: 2010/09/08 19:14 by Deviloper
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki