xoreos  0.0.5
fpscounter.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_FPSCOUNTER_H
26 #define GRAPHICS_FPSCOUNTER_H
27 
28 #include "src/common/types.h"
29 #include "src/common/scopedptr.h"
30 
31 namespace Graphics {
32 
34 class FPSCounter {
35 public:
37  FPSCounter(size_t secs);
38  ~FPSCounter();
39 
41  uint32 getFPS() const;
42 
44  void reset();
45 
47  void finishedFrame();
48 
49 private:
51 
52  size_t _seconds;
53  size_t _currentSecond;
54 
56 
58 
60 
61  void calculateFPS();
62 };
63 
64 } // End of namespace Graphics
65 
66 #endif // GRAPHICS_FPSCOUNTER_H
size_t _seconds
Number of seconds over which to average the FPS.
Definition: fpscounter.h:52
size_t _currentSecond
Current second we measure.
Definition: fpscounter.h:53
Common::ScopedArray< uint32 > _frames
All frame counters.
Definition: fpscounter.h:59
void calculateFPS()
Calculate the average FPS value.
Definition: fpscounter.cpp:91
A simple scoped smart pointer template.
A class counting frames per second.
Definition: fpscounter.h:34
FPSCounter(size_t secs)
Average the FPS over that many seconds.
Definition: fpscounter.cpp:35
void reset()
Reset the counter.
Definition: fpscounter.cpp:50
Low-level type definitions to handle fixed width types portably.
uint32 _fps
The current FPS value.
Definition: fpscounter.h:57
bool _hasFullSeconds
Got all samples?
Definition: fpscounter.h:55
uint32 getFPS() const
Get the current FPS value.
Definition: fpscounter.cpp:46
uint32_t uint32
Definition: types.h:204
uint32 _lastSampled
The last time a finished frame was signaled.
Definition: fpscounter.h:50
void finishedFrame()
Signal a finished frame.
Definition: fpscounter.cpp:63