]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/od_gauge.hxx
initialize variables before using them
[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 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 //
22
23 #ifndef _OD_GAUGE_HXX
24 #define _OD_GAUGE_HXX
25
26 #include <osg/Texture2D>
27
28 #include <simgear/structure/subsystem_mgr.hxx>
29
30 /**
31  * Owner Drawn Gauge helper class.
32  */
33 class FGODGauge : public SGSubsystem {
34
35 public:
36     FGODGauge ( SGPropertyNode *node );
37     FGODGauge();
38     ~FGODGauge();
39     virtual void init ();
40     virtual void update (double dt);
41
42     /**
43      * Start the rendering of the RTT context.
44      * @param viewSize size of the destination texture 
45      */
46     void beginCapture(int viewSize);
47     /**
48      * Start the rendering of the RTT context.
49      */
50     void beginCapture(void);
51     /**
52      * Clear the background.
53      */
54     void Clear(void);
55     /**
56      * Finish rendering and save the buffer to a texture.
57      * @param texID name of a gl texture
58      */
59     void endCapture(osg::Texture2D*);
60     /**
61      * Set the size of the destination texture.
62      * @param viewSize size of the destination texture 
63      */
64     void setSize(int viewSize);
65     /**
66      * Say if we can render to a texture.
67      * @return true if rtt is available
68      */
69     bool serviceable(void);
70     /**
71      * Replace an opengl texture name inside the aircraft scene graph.
72      * This is to replace a static texture by a dynamic one
73      * @param name texture filename
74      * @param new_texture dynamic texture to replace the old one
75      */
76     void set_texture(const char * name, osg::Texture2D* new_texture);
77
78 private:
79     int textureWH;
80     bool rtAvailable;
81
82     void allocRT(void);
83     void set2D(void);
84     void set3D(void);
85 };
86
87 #endif // _OD_GAUGE_HXX