]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/od_gauge.hxx
NavDisplay enhancements for Syd.
[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
29 #include <osg/ref_ptr>
30
31 namespace osg {
32   class Camera;
33   class Texture2D;
34 }
35
36 /**
37  * Owner Drawn Gauge helper class.
38  */
39 class FGODGauge
40 {
41 public:
42     FGODGauge();
43     virtual ~FGODGauge();
44
45   
46     void setSize(int viewSize);
47     int size() const
48         { return textureWH; }
49     
50     /**
51      * Say if we can render to a texture.
52      * @return true if rtt is available
53      */
54     bool serviceable(void);
55
56     /**
57      * Replace an opengl texture name inside the aircraft scene graph.
58      * This is to replace a static texture by a dynamic one
59      * @param name texture filename
60      * @param new_texture dynamic texture to replace the old one
61      */
62     void set_texture(const char * name, osg::Texture2D* new_texture);
63
64     /**
65      * Get the OSG camera for drawing this gauge.
66      */
67     osg::Camera* getCamera() { return camera.get(); }
68
69     osg::Texture2D* getTexture() { return texture.get(); }
70     void setTexture(osg::Texture2D* t) { texture = t; }
71
72     // Real initialization function. Bad name.
73     void allocRT(void);
74
75 private:
76     int textureWH;
77     bool rtAvailable;
78     osg::ref_ptr<osg::Camera> camera;
79     osg::ref_ptr<osg::Texture2D> texture;
80
81 };
82
83 #endif // _OD_GAUGE_HXX