Files
qt5-legatus-legacy/Lts/Plugins/BuildingViewer/Common/BgViewer/viewerCtrl/windowcapturecallback.h
T
2026-08-13 18:33:10 +02:00

92 lines
2.9 KiB
C++
Executable File

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial applications,
* as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/* -*-c++-*-
*
* Copyright (C) 2009 Cedric Pinson
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Authors:
* Cedric Pinson <cedric.pinson@plopbyte.net>
*
*/
#pragma once
#include <osg/Camera>
// fwd decl for gstreamer objects
struct _GstElement;
namespace VCtrl
{
class WindowCaptureCallback : public osg::Camera::DrawCallback
{
public:
struct ContextData : public osg::Referenced
{
ContextData(osg::GraphicsContext *gc, GLenum readBuffer, const std::string &path, int w, int h, int framerate, int quality);
~ContextData();
static void getSize(osg::GraphicsContext *gc, int &width, int &height);
void read();
osg::GraphicsContext *_gc;
GLenum _readBuffer;
std::string _fileName;
int _width;
int _height;
std::vector< GLuint > _pboBuffer;
osg::Timer_t _previousFrameTick;
osg::Timer_t _startTick;
_GstElement *_pipeline;
_GstElement *_app_source;
};
WindowCaptureCallback(GLenum readBuffer, unsigned int contextid, const std::string &path, int w, int h, int framerate, int quality);
~WindowCaptureCallback() = default;
ContextData *createContextData(osg::GraphicsContext *gc) const;
ContextData *getContextData(osg::GraphicsContext *gc) const;
void operator()(osg::RenderInfo &renderInfo) const override;
using ContextDataMap = std::map<osg::GraphicsContext *, osg::ref_ptr<ContextData> >;
GLenum _readBuffer;
unsigned int _contextId;
std::string _filename;
int _w;
int _h;
int _framerate;
int _quality;
mutable ContextDataMap _contextDataMap;
};
}