]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/od_gauge.hxx
Win32 fixes
[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
27 #include <plib/ssg.h>
28 #include <simgear/structure/subsystem_mgr.hxx>
29
30 class RenderTexture;
31
32 /**
33  * Owner Drawn Gauge helper class.
34  */
35 class FGODGauge : public SGSubsystem {
36
37 public:
38     FGODGauge ( SGPropertyNode *node );
39     FGODGauge();
40     ~FGODGauge();
41     virtual void init ();
42     virtual void update (double dt);
43
44     /**
45      * Start the rendering of the RTT context.
46      * @param viewSize size of the destination texture 
47      */
48     void beginCapture(int viewSize);
49     /**
50      * Start the rendering of the RTT context.
51      */
52     void beginCapture(void);
53     /**
54      * Clear the background.
55      */
56     void Clear(void);
57     /**
58      * Finish rendering and save the buffer to a texture.
59      * @param texID name of a gl texture
60      */
61     void endCapture(GLuint texID);
62     /**
63      * Set the size of the destination texture.
64      * @param viewSize size of the destination texture 
65      */
66     void setSize(int viewSize);
67     /**
68      * Say if we can render to a texture.
69      * @return true if rtt is available
70      */
71     bool serviceable(void);
72     /**
73      * Replace an opengl texture name inside the aircraft scene graph.
74      * This is to replace a static texture by a dynamic one
75      * @param name texture filename
76      * @param new_texture dynamic texture to replace the old one
77      */
78     void set_texture(const char * name, GLuint new_texture);
79
80 private:
81     int textureWH;
82     RenderTexture *rt;
83     bool rtAvailable;
84
85     void allocRT(void);
86     void set2D(void);
87     void set3D(void);
88 };
89
90 #endif // _OD_GAUGE_HXX