-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFps.cpp
More file actions
73 lines (59 loc) · 1.78 KB
/
Fps.cpp
File metadata and controls
73 lines (59 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fps.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: afaucher <afaucher@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/10 14:14:01 by afaucher #+# #+# */
/* Updated: 2015/02/23 15:04:32 by afaucher ### ########.fr */
/* */
/* ************************************************************************** */
#include "Fps.hpp"
Fps::Fps( void ) : _m_fps(0), _m_fpscount(0)
{
return ;
}
Fps::Fps(Fps const & src)
{
*this = src;
return ;
}
Fps::~Fps( void )
{
return ;
}
Fps & Fps::operator=(Fps const & rhs)
{
this->_m_fps = rhs._m_fps;
this->_m_fpscount = rhs._m_fpscount;
this->_m_fpsinterval = rhs._m_fpsinterval;
return *this;
}
std::string Fps::toString() const
{
std::ostringstream ostr;
ostr << "FPS : fps :" << this->_m_fps << " fps count " << this->_m_fpscount
<< " fps interval " << this->_m_fpsinterval << std::endl;
return ostr.str();
}
void Fps::update()
{
this->_m_fpscount++;
if (this->_m_fpsinterval.value() > CLOCKS_PER_SEC)
{
this->_m_fps = this->_m_fpscount;
this->_m_fpscount = 0;
this->_m_fpsinterval.refresh();
}
return ;
}
unsigned int Fps::get() const
{
return this->_m_fps;
}
std::ostream & operator<<(std::ostream & o, Fps const & rhs)
{
o << rhs.toString();
return o;
}