]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/od_gauge.hxx
Merge branch 'maint2' into next
[flightgear.git] / src / Instrumentation / od_gauge.hxx
1 // Owner Drawn Gauge helper class
2 //
3 // Written by Harald JOHNSEN, started May 2005.
4 //
5 // Copyright (C) 2005  Harald JOHNSEN - hjohnsen@evc.net
6 //
7 // Ported to OSG by Tim Moore - Jun 2007
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22 //
23 //
24
25 #ifndef _OD_GAUGE_HXX
26 #define _OD_GAUGE_HXX
27
28 #include <osg/Camera>
29 #include <osg/Texture2D>
30
31 #include <simgear/structure/subsystem_mgr.hxx>
32
33 /**
34  * Owner Drawn Gauge helper class.
35  */
36 class FGODGauge : public SGSubsystem {
37
38 public:
39     FGODGauge ( SGPropertyNode *node );
40     FGODGauge();
41     ~FGODGauge();
42     virtual void init ();
43     virtual void update (double dt);
44
45     void setSize(int viewSize);
46
47     /**
48      * Say if we can render to a texture.
49      * @return true if rtt is available
50      */
51     bool serviceable(void);
52
53     /**
54      * Replace an opengl texture name inside the aircraft scene graph.
55      * This is to replace a static texture by a dynamic one
56      * @param name texture filename
57      * @param new_texture dynamic texture to replace the old one
58      */
59     void set_texture(const char * name, osg::Texture2D* new_texture);
60
61     /**
62      * Get the OSG camera for drawing this gauge.
63      */
64     osg::Camera* getCamera() { return camera.get(); }
65
66     osg::Texture2D* getTexture() { return texture.get(); }
67     void setTexture(osg::Texture2D* t) { texture = t; }
68
69     // Real initialization function. Bad name.
70     void allocRT(void);
71
72 private:
73     int textureWH;
74     bool rtAvailable;
75     osg::ref_ptr<osg::Camera> camera;
76     osg::ref_ptr<osg::Texture2D> texture;
77
78 };
79
80 #endif // _OD_GAUGE_HXX