A manager for asynchronous readbacks from a framebuffer. More...
#include <ReadbackManager.h>
Classes | |
class | Callback |
A callback function called when a readback is done; see ReadbackManager. More... | |
Public Member Functions | |
ReadbackManager (int maxReadbackPerFrame, int readbackDelay, int bufferSize) | |
Creates a new readback manager. | |
virtual | ~ReadbackManager () |
Destroys this readback manager. | |
bool | canReadback () |
Returns true if a new readback can be started for the current frame. | |
bool | readback (ptr< FrameBuffer > fb, int x, int y, int w, int h, TextureFormat f, PixelType t, ptr< Callback > cb) |
Starts a new readback and returns immediately. | |
void | newFrame () |
Informs this manager that a new frame has started. |
A manager for asynchronous readbacks from a framebuffer.
Asynchronous means that readbacks are non blocking: a read operation returns immediately with an empty result, and the actual result is passed via a callback function when it becomes available (in practice n frames after the read was started, where n is user defined).
proland::ReadbackManager::ReadbackManager | ( | int | maxReadbackPerFrame, | |
int | readbackDelay, | |||
int | bufferSize | |||
) |
Creates a new readback manager.
maxReadbackPerFrame | maximum number of readbacks that can be started per frame. | |
readbackDelay | number of frames between the start of a readback and its end. | |
bufferSize | maximum number of bytes per readback. |
virtual proland::ReadbackManager::~ReadbackManager | ( | ) | [virtual] |
Destroys this readback manager.
bool proland::ReadbackManager::canReadback | ( | ) |
Returns true if a new readback can be started for the current frame.
void proland::ReadbackManager::newFrame | ( | ) |
Informs this manager that a new frame has started.
bool proland::ReadbackManager::readback | ( | ptr< FrameBuffer > | fb, | |
int | x, | |||
int | y, | |||
int | w, | |||
int | h, | |||
TextureFormat | f, | |||
PixelType | t, | |||
ptr< Callback > | cb | |||
) |
Starts a new readback and returns immediately.
Returns true if the readback has effectively started (see canReadback()).
fb | the framebuffer from which the data must be read. Data will be read from the last buffer specified with FrameBuffer::setReadBuffer for this framebuffer. | |
x | x coordinate of the lower left corner of the region to be read. | |
y | x coordinate of the lower left corner of the region to be read. | |
w | width of the region to be read. | |
h | height the region to be read. | |
f | the components to be read. | |
t | the type to be used to store the read data. | |
cb | the function to be called when the readback is finished. |