1 // Copyright (C) 2009 - 2012 Mathias Froehlich
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.
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.
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.
17 #ifndef _fgviewer_Drawable_hxx
18 #define _fgviewer_Drawable_hxx
22 #include <osg/GraphicsContext>
23 #include <simgear/math/SGMath.hxx>
24 #include <simgear/structure/SGWeakReferenced.hxx>
31 class Drawable : public SGWeakReferenced {
33 Drawable(const std::string& name);
36 const std::string& getName() const
39 virtual bool setScreenIdentifier(const std::string& screenIdentifier)
41 if (_graphicsContext.valid())
43 _screenIdentifier = screenIdentifier;
46 const std::string& getScreenIdentifier() const
47 { return _screenIdentifier; }
49 virtual bool setPosition(const SGVec2i& position)
50 { _position = position; return true; }
51 const SGVec2i& getPosition() const
54 virtual bool setSize(const SGVec2i& size)
55 { _size = size; return true; }
56 const SGVec2i& getSize() const
59 virtual bool setOffscreen(bool offscreen)
61 if (_graphicsContext.valid())
63 _offscreen = offscreen;
66 bool getOffscreen() const
67 { return _offscreen; }
69 virtual bool setFullscreen(bool fullscreen)
70 { _fullscreen = fullscreen; return true; }
71 bool getFullscreen() const
72 { return _fullscreen; }
74 osg::GraphicsContext* getGraphicsContext()
75 { return _graphicsContext.get(); }
77 void attachSlaveCamera(SlaveCamera* slaveCamera);
79 virtual bool resize(int x, int y, int width, int height);
81 bool realize(Viewer& viewer);
84 virtual osg::GraphicsContext* _realizeImplementation(Viewer& viewer);
85 osg::ref_ptr<osg::GraphicsContext::Traits> _getTraits(Viewer& viewer);
88 Drawable(const Drawable&);
89 Drawable& operator=(const Drawable&);
91 class _ResizedCallback;
93 /// The immutable name that is used to reference this slave camera.
94 const std::string _name;
95 std::string _screenIdentifier;
100 osg::ref_ptr<osg::GraphicsContext> _graphicsContext;
101 std::list<SGSharedPtr<SlaveCamera> > _slaveCameraList;
104 } // namespace fgviewer