-
Notifications
You must be signed in to change notification settings - Fork 1
frame_generator
Alexandre Marcireau edited this page Jun 2, 2018
·
2 revisions
In header "../third_party/chameleon/source/frame_generator.hpp"
chameleon::frame_generator
takes screenshots of the window. Any modification to a Chameleon display before calling chameleon::frame_generator::save_frame_to
is guaranteed to appear in the resulting frame.
namespace chameleon {
class frame_generator : public QQuickItem {
Q_OBJECT
public:
frame_generator();
/// save_frame_to triggers a frame render and stores the resulting png image to the given file.
virtual void save_frame_to(const std::string& filename);
public slots:
/// sync adapts the renderer to external changes.
void sync();
/// cleanup frees the owned renderer.
void cleanup();
/// trigger_draw requests a window refresh.
void trigger_draw();
/// closing is called when the window is about to be closed.
void closing();
};
}
-
filename
is the absolute path (or relative to the current working directory) of the output file.save_frame_to
will fail if the parent directory does not exist.
chameleon::frame_generator
is associated with a chameleon::frame_generator_renderer
to handle OpenGL calls.
namespace chameleon {
class frame_generator_renderer : public QObject, public QOpenGLFunctions_3_3_Core {
Q_OBJECT
public:
frame_generator_renderer();
/// set_rendering_area defines the rendering area.
virtual void set_rendering_area(QRectF capture_area, int window_height);
/// save_frame_to waits for a complete render, takes a screenshots and writes it to a file.
virtual bool save_frame_to(const QString& filename);
public slots:
/// before_rendering_callback must be called when the window is about to be rendered.
void before_rendering_callback();
/// after_rendering_callback must be called when the window completes a rendering.
void after_rendering_callback();
/// closing is called when the window is about to be closed.
void closing();
};
}
-
capture_area
is the rectangle to capture, in screen coordinates. -
window_height
is the total window height (used to convert from Qt coordinates to OpenGL coordinates).
before_rendering_callback
and after_rendering_callback
are used to synchronize screenshots and calls to save_frame_to
.
A typical QML instantiation has the following syntax:
FrameGenerator {}