Dragonfly  4.3
A text-based game engine
Fraps.h
1 ///
2 /// Fraps (FRAmes Per Second) recorder
3 ///
4 
5 #ifndef __FRAPS_H__
6 #define __FRAPS_H__
7 
8 #include <stdio.h>
9 
10 #include "Clock.h"
11 #include "Event.h"
12 #include "ViewObject.h"
13 
14 namespace df {
15 
16 const std::string FRAPS_STRING = "fps";
17 const std::string FRAPS_FILENAME = "fraps";
18 #define FRAPS_LOG_MESSAGE "Fraps: frame rate %.0f f/s"
19 
20 class Fraps : public ViewObject {
21 
22  private:
23  bool m_do_record; ///< True if recording.
24  bool m_do_frame_rate; ///< True if logging frame rate.
25  Clock m_clock; ///< For computing frame rate.
26  FILE *m_p_screen; ///< Output file handle.
27 
28  public:
29  /// Frames per second meter (with option to record screen).
30  /// defaults: TOP_RIGHT, green, don't record, don't log frame rate.
31  Fraps(bool do_record=false);
32  ~Fraps();
33 
34  /// Handle event each step.
35  /// Handle keyboard events:
36  /// - f9 to show/hide
37  /// - f11 to toggle logging frame rate
38  /// - f12 to toggle recording
39  int eventHandler(const Event *p_e);
40 
41  /// Set whether record or not.
42  void setRecord(bool new_record);
43 
44  /// Set whether log frame rate or not.
45  void setLogFrameRate(bool new_do_frame_rate);
46 };
47 
48 } // end of namespace df
49 #endif
Definition: ViewObject.h:45
Fraps(bool do_record=false)
Frames per second meter (with option to record screen).
bool m_do_frame_rate
True if logging frame rate.
Definition: Fraps.h:24
Definition: Event.h:15
A 2-d bounding box.
Definition: Box.h:10
Clock m_clock
For computing frame rate.
Definition: Fraps.h:25
bool m_do_record
True if recording.
Definition: Fraps.h:23
int eventHandler(const Event *p_e)
Handle event each step.
void setLogFrameRate(bool new_do_frame_rate)
Set whether log frame rate or not.
void setRecord(bool new_record)
Set whether record or not.
FILE * m_p_screen
Output file handle.
Definition: Fraps.h:26
Definition: Clock.h:10
Definition: Fraps.h:20