| 1 | // Copyright (C) 2017 James Turner |
| 2 | // |
| 3 | // This program is free software; you can redistribute it and/or |
| 4 | // modify it under the terms of the GNU General Public License as |
| 5 | // published by the Free Software Foundation; either version 2 of the |
| 6 | // License, or (at your option) any later version. |
| 7 | // |
| 8 | // This program is distributed in the hope that it will be useful, but |
| 9 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | // General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with this program; if not, write to the Free Software |
| 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 | |
| 17 | #ifndef PUICAMERA_HXX |
| 18 | #define PUICAMERA_HXX |
| 19 | |
| 20 | #include <osg/Camera> |
| 21 | #include <osg/Version> |
| 22 | #include <osgViewer/View> |
| 23 | |
| 24 | namespace osg |
| 25 | { |
| 26 | class Texture2D; |
| 27 | class Geometry; |
| 28 | } |
| 29 | |
| 30 | namespace osgViewer { |
| 31 | class Viewer; |
| 32 | } |
| 33 | |
| 34 | namespace osgGA { |
| 35 | class GUIEventHandler; |
| 36 | } |
| 37 | |
| 38 | namespace flightgear |
| 39 | { |
| 40 | |
| 41 | class PUICamera : public osg::Camera |
| 42 | { |
| 43 | public: |
| 44 | static void initPUI(); |
| 45 | |
| 46 | PUICamera(); |
| 47 | virtual ~PUICamera(); |
| 48 | |
| 49 | osg::Object* cloneType() const override { return new PUICamera; } |
| 50 | osg::Object* clone(const osg::CopyOp&) const override { return new PUICamera; } |
| 51 | |
| 52 | // osg::Camera already defines a resize() so use this name |
| 53 | void resizeUi(int width, int height); |
| 54 | |
| 55 | void init(osg::Group* parent, osgViewer::View* view); |
| 56 | |
| 57 | private: |
| 58 | void manuallyResizeFBO(int width, int height); |
| 59 | |
| 60 | osg::Texture2D* _fboTexture = nullptr; |
| 61 | osg::Geometry* _fullScreenQuad = nullptr; |
| 62 | osgGA::GUIEventHandler* _eventHandler = nullptr; |
| 63 | |
| 64 | static void puGetWindowSize(int *width, int *height); |
| 65 | static int puGetWindow(); |
| 66 | }; |
| 67 | |
| 68 | } // of namespace flightgear |
| 69 | |
| 70 | #endif // PUICAMERA_HXX |