An EventHandler that can record and replay events, and save a video during replay. More...
#include <EventRecorder.h>
Classes | |
struct | Event |
A recorded event. More... | |
Public Member Functions | |
EventRecorder (const char *eventFile, bool autoSave, const char *frames, ptr< Program > cursorProg, ptr< Texture2D > cursor, ptr< EventHandler > next) | |
Creates a new EventRecorder. | |
virtual | ~EventRecorder () |
Deletes this EventRecorder. | |
Protected Member Functions | |
EventRecorder () | |
Creates an uninitialized EventRecorder. | |
void | init (const char *eventFile, bool autoSave, const char *frames, ptr< Program > cursorProg, ptr< Texture2D > cursor, ptr< EventHandler > next) |
Initializes this EventRecorder. | |
virtual Recordable * | getRecorded ()=0 |
Returns the used to save/restore the framerate and the scene state. | |
Protected Attributes | |
Recordable * | r |
The object used to save/restore the framerate and the scene state. | |
Private Member Functions | |
void | saveFrame (char *tga) |
Saves the framebuffer content to the given TGA file. | |
void | saveEvents () |
Saves the recorded events to a temporary file if autoSave is true. | |
Private Attributes | |
const char * | eventFile |
The name of a file containing stored events to be replayed, or NULL. | |
bool | autoSave |
True to save events in a temporary file at each mouse click and key typed event (useful for saving events if scenario leads to a crash). | |
const char * | frames |
The file name format to be used to save the video frames. | |
int | cursW |
The width of the cursor texture cursor. | |
int | cursH |
The height of the cursor texture cursor. | |
ptr< Program > | cursorProg |
The GLSL program used to draw the cursor on replaying videos. | |
ptr< Texture2D > | cursor |
The cursor RGBA texture pixels. | |
ptr< UniformSampler > | cursorSamplerU |
The cursor texture sampler. | |
ptr< Uniform4f > | rescaleU |
Rescaling factor used to draw the cursor on the screen. | |
ptr< Uniform3f > | correctU |
Rescaling factor used to draw the cursor on the screen. | |
bool | isRecording |
True if this EventHandler is currently recording events. | |
bool | isPlaying |
True if this EventHandler is currently replaying events. | |
bool | saveVideo |
True if a video must be saved during replaying. | |
int | lastSavedEvent |
The index of the recorded event corresponding to the last saved video frame. | |
int | lastSavedFrame |
The index of the last saved video frame. | |
int | savedX |
The x cursor position of the last replayed mouse event. | |
int | savedY |
The x cursor position of the last replayed mouse event. | |
unsigned int | lastPlayed |
The index of the last replayed event. | |
vector< Event > | recordedEvents |
The recorded events. | |
ptr< EventHandler > | next |
The EventHandler that must handle the events recorded and replayed by this EventRecorder. |
An EventHandler that can record and replay events, and save a video during replay.
Recording is started and stopped with F12. Replay is triggered with F11, or SHIFT+F11 to record a video while replaying. The recorded video does not contain all the original frames, but only 25 frames per second. Since replay cannot be done at the same rate as the original events, especially when saving a video, the events are recorded together with the time at which they originally occured, to be able to override the real-time during replay with the original time during recording. Also if modifications have been performed to the scene during the recording, the initial scene state must be restored before replaying the event. This is managed by a Recordable, that is used by this EventRecorder.
proland::EventRecorder::EventRecorder | ( | const char * | eventFile, | |
bool | autoSave, | |||
const char * | frames, | |||
ptr< Program > | cursorProg, | |||
ptr< Texture2D > | cursor, | |||
ptr< EventHandler > | next | |||
) |
Creates a new EventRecorder.
eventFile | the name of a file containing stored events to be replayed, or NULL. | |
autoSave | true to save events in a temporary file at each mouse click and key typed event (useful for saving events if scenario leads to a crash). | |
frames | the file name format to be used to save the video frames. For instance "video/frame-%d.tga" or "video/frame-%.4d.tga". | |
cursorProg | the GLSL program used to draw the cursor on the screen. | |
cursor | a cursor texture to display the cursor position during replay. | |
next | the EventHandler that must handle the events recorded and replayed by this EventRecorder. |
virtual proland::EventRecorder::~EventRecorder | ( | ) | [virtual] |
Deletes this EventRecorder.
proland::EventRecorder::EventRecorder | ( | ) | [protected] |
Creates an uninitialized EventRecorder.
virtual Recordable* proland::EventRecorder::getRecorded | ( | ) | [protected, pure virtual] |
Returns the used to save/restore the framerate and the scene state.
void proland::EventRecorder::init | ( | const char * | eventFile, | |
bool | autoSave, | |||
const char * | frames, | |||
ptr< Program > | cursorProg, | |||
ptr< Texture2D > | cursor, | |||
ptr< EventHandler > | next | |||
) | [protected] |
Initializes this EventRecorder.
See EventRecorder.
void proland::EventRecorder::saveEvents | ( | ) | [private] |
Saves the recorded events to a temporary file if autoSave is true.
void proland::EventRecorder::saveFrame | ( | char * | tga | ) | [private] |
Saves the framebuffer content to the given TGA file.
tga | a TGA file name. |
bool proland::EventRecorder::autoSave [private] |
True to save events in a temporary file at each mouse click and key typed event (useful for saving events if scenario leads to a crash).
ptr<Uniform3f> proland::EventRecorder::correctU [private] |
Rescaling factor used to draw the cursor on the screen.
int proland::EventRecorder::cursH [private] |
The height of the cursor texture cursor.
ptr<Texture2D> proland::EventRecorder::cursor [private] |
The cursor RGBA texture pixels.
ptr<Program> proland::EventRecorder::cursorProg [private] |
The GLSL program used to draw the cursor on replaying videos.
ptr<UniformSampler> proland::EventRecorder::cursorSamplerU [private] |
The cursor texture sampler.
int proland::EventRecorder::cursW [private] |
The width of the cursor texture cursor.
const char* proland::EventRecorder::eventFile [private] |
The name of a file containing stored events to be replayed, or NULL.
const char* proland::EventRecorder::frames [private] |
The file name format to be used to save the video frames.
bool proland::EventRecorder::isPlaying [private] |
True if this EventHandler is currently replaying events.
bool proland::EventRecorder::isRecording [private] |
True if this EventHandler is currently recording events.
unsigned int proland::EventRecorder::lastPlayed [private] |
The index of the last replayed event.
int proland::EventRecorder::lastSavedEvent [private] |
The index of the recorded event corresponding to the last saved video frame.
int proland::EventRecorder::lastSavedFrame [private] |
The index of the last saved video frame.
ptr<EventHandler> proland::EventRecorder::next [private] |
The EventHandler that must handle the events recorded and replayed by this EventRecorder.
Recordable* proland::EventRecorder::r [protected] |
The object used to save/restore the framerate and the scene state.
vector<Event> proland::EventRecorder::recordedEvents [private] |
The recorded events.
ptr<Uniform4f> proland::EventRecorder::rescaleU [private] |
Rescaling factor used to draw the cursor on the screen.
int proland::EventRecorder::savedX [private] |
The x cursor position of the last replayed mouse event.
int proland::EventRecorder::savedY [private] |
The x cursor position of the last replayed mouse event.
bool proland::EventRecorder::saveVideo [private] |
True if a video must be saved during replaying.