Dragonfly 4.20
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// System includes.
9#include <stdio.h>
10#include <SFML/Graphics.hpp>
11
12// Engine includes.
13#include "Clock.h"
14#include "Event.h"
15#include "ViewObject.h"
16
17namespace df {
18
19const std::string FRAPS_STRING = "fps";
20const std::string FRAPS_FILENAME = "fraps";
21#define FRAPS_LOG_MESSAGE "Fraps: frame rate %.0f f/s"
22
23class Fraps : public ViewObject {
24
25 private:
26 bool m_do_record; ///< True if recording.
27 bool m_do_frame_rate; ///< True if logging frame rate.
28 Clock m_clock; ///< For computing frame rate.
29 FILE *m_p_screen; ///< Output file handle.
30 sf::Texture m_texture; ///< Texture for image capture.
31
32 public:
33 /// Frames per second meter (with option to record screen).
34 /// defaults: TOP_RIGHT, green, don't record, don't log frame rate.
35 Fraps(bool do_record=false);
36 ~Fraps();
37
38 /// Handle event each step.
39 /// Handle keyboard events:
40 /// - f9 to show/hide
41 /// - f11 to toggle logging frame rate
42 /// - f12 to toggle recording
43 int eventHandler(const Event *p_e) override;
44
45 /// Set whether record or not.
46 void setRecord(bool new_record);
47
48 /// Set whether log frame rate or not.
49 void setLogFrameRate(bool new_do_frame_rate);
50};
51
52} // end of namespace df
53#endif
Definition: Clock.h:10
Definition: Event.h:15
Definition: Fraps.h:23
bool m_do_record
True if recording.
Definition: Fraps.h:26
void setRecord(bool new_record)
Set whether record or not.
sf::Texture m_texture
Texture for image capture.
Definition: Fraps.h:30
Clock m_clock
For computing frame rate.
Definition: Fraps.h:28
FILE * m_p_screen
Output file handle.
Definition: Fraps.h:29
int eventHandler(const Event *p_e) override
Handle event each step.
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:27
void setLogFrameRate(bool new_do_frame_rate)
Set whether log frame rate or not.
Definition: ViewObject.h:39
An animation for a sprite.
Definition: Animation.h:15