25 #include <osg/BufferObject>
27 #include "animation/WGEAnimationFrameTimer.h"
29 #include "WGEScreenCapture.h"
36 w->get().m_frames = 0;
37 w->get().m_framesLeft = 0;
68 w->get().m_framesLeft = frames;
74 return r->get().m_framesLeft;
89 osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext();
94 GLenum pixelFormat = GL_RGB;
97 width = gc->getTraits()->width;
98 height = gc->getTraits()->height;
99 pixelFormat = gc->getTraits()->alpha ? GL_RGBA : GL_RGB;
107 #ifndef GL_ES_VERSION_2_0
108 glReadBuffer( GL_BACK );
142 osg::ref_ptr< osg::Image > image =
new osg::Image();
143 image->readPixels( 0, 0, width, height, pixelFormat, GL_UNSIGNED_BYTE );
165 w->get().m_frames = 0;
std::shared_ptr< const WCondition > ConstSPtr
Const shared pointer type for WCondition.
Frame-based animation timing.
std::shared_ptr< const WGEAnimationFrameTimer > ConstSPtr
Convenience typedef for a const shared_ptr.
void recordStop()
Stops recording.
void record(size_t frames=std::numeric_limits< size_t >::max())
Starts recording.
virtual ~WGEScreenCapture()
Destructor.
SharedRecordingInformation m_recordingInformation
Counts the frames to take.
boost::function< void(size_t, size_t, osg::ref_ptr< osg::Image >) > HandleImageCallbackType
This callback signature is needed to subscribe to the handleImage signal.
WGEAnimationFrameTimer::ConstSPtr getFrameTimer() const
Returns a timer getting ticked on each recorded frame.
WCondition::ConstSPtr getRecordCondition() const
The condition returned here is actually the change condition of the frame counter.
void recordStart()
Starts recording.
SharedRecordingInformation::ReadTicket getRecordingInformation() const
Returns the current recording information.
virtual void operator()(osg::RenderInfo &renderInfo) const
The draw callback operator.
WGEAnimationFrameTimer::SPtr m_timer
The frame timer.
void screenshot()
Makes a screenshot with the next frame.
WGEScreenCapture()
Creates a screen capture callback.
HandleImageSignalType m_signalHandleImage
The signal emitted on every new grabbed image.
virtual void handleImage(size_t framesLeft, size_t totalFrames, osg::ref_ptr< osg::Image > image) const
The function handles new images.
void resetFrameCounter()
Resets the frame-counter to 0.
boost::signals2::connection subscribeSignal(HandleImageCallbackType callback)
Subscribes a specified function to the new-image-signal.
bool isRecording()
Checks if there are frames left for recording.
std::shared_ptr< WSharedObjectTicketRead< RecordingInformation > > ReadTicket
Type for read tickets.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
std::shared_ptr< WSharedObjectTicketWrite< RecordingInformation > > WriteTicket
Type for write tickets.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.
std::shared_ptr< WCondition > getChangeCondition() const
This condition fires whenever the encapsulated object changed.