]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/panel.hxx
21f82662d34be44014ab06d49dc801353a09c58a
[flightgear.git] / src / Cockpit / panel.hxx
1 //  panel.hxx -- instrument panel defines and prototypes
2 // 
3 //  Written by Friedemann Reinhard, started June 1998.
4 //
5 //  Major code reorganization by David Megginson, November 1999.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 //  $Id$
22
23
24 #ifndef _PANEL_HXX
25 #define _PANEL_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H          
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <XGL/xgl.h>
43
44 class FGInstrument;             // FIXME: rearrange to avoid this?
45
46
47 /**
48  * Top-level class to hold an instance of a panel.
49  */
50 class FGPanel{
51
52 public:
53   static FGPanel *OurPanel;     // current_panel would be better
54
55                                 // FIXME: a few other classes have a
56                                 // dependency on this information; it
57                                 // would be nice to fix that.
58   GLuint panel_tex_id[2];
59
60   FGPanel();
61   virtual ~FGPanel ();
62   virtual float get_height(void) { return height; }
63   virtual void ReInit( int x, int y, int finx, int finy);
64   virtual void Update(void);
65
66 private:
67
68   int height;
69   int width;
70   GLubyte *background;
71   GLubyte *imag;
72   int imag_width, imag_height;
73   GLubyte *img;
74   int img_width, img_height;
75                                 // The instruments on the panel.
76   FGInstrument * horizonIndicator;
77   FGInstrument * turnCoordinator;
78   FGInstrument * rpmIndicator;
79   FGInstrument * airspeedIndicator;
80   FGInstrument * verticalSpeedIndicator;
81   FGInstrument * altimeter;
82   FGInstrument * altimeter2;
83 };
84
85
86 /**
87  * Abstract base class for all panel instruments.
88  */
89 class FGInstrument{
90
91 public:
92   FGInstrument (void) {}
93   virtual ~FGInstrument (void) {}
94   virtual void Init(void) = 0;
95   virtual void Render(void) = 0;
96
97 protected:
98   float XPos;
99   float YPos;
100 };
101
102
103 /**
104  * Instrument: the artificial horizon.
105  */
106 class FGHorizon : public FGInstrument 
107 {
108
109 public:
110   FGHorizon (float inXPos, float inYPos);
111   virtual ~FGHorizon (void);
112   virtual void Init (void);
113   virtual void Render (void);
114         
115 private:
116   float texXPos;
117   float texYPos;
118   float radius;
119   float bottom;   // tell the program the offset between midpoint and bottom 
120   float top;      // guess what ;-)
121   float vertices[180][2];
122   float normals[180][3];
123   float texCoord[180][2];
124 };
125
126
127 /**
128  * Instrument: the turn co-ordinator.
129  */
130 class FGTurnCoordinator : public FGInstrument 
131 {
132
133 public:
134   FGTurnCoordinator (float inXPos, float inYPos);
135   virtual FGTurnCoordinator::~FGTurnCoordinator (void);
136   virtual void Init (void);
137   virtual void Render(void);
138   
139 private:
140   float PlaneTexXPos;
141   float PlaneTexYPos;
142   float alpha;
143   float PlaneAlpha;
144   float alphahist[2];
145   float rollhist[2];
146   float BallXPos;
147   float BallYPos;
148   float BallTexXPos;
149   float BallTexYPos;
150   float BallRadius;
151   GLfloat vertices[72];
152   static GLfloat wingArea[];
153   static GLfloat elevatorArea[];
154   static GLfloat rudderArea[];
155 };
156
157
158 /**
159  * Abstract base class for gauges with needles and textured backgrounds.
160  *
161  * The airspeed indicator, vertical speed indicator, altimeter, and RPM 
162  * gauge are all derived from this class.
163  */
164 class FGTexInstrument : public FGInstrument 
165 {
166 public:
167   FGTexInstrument (void);
168   virtual ~FGTexInstrument ();
169   virtual void Init(void);
170   virtual void Render(void);
171   
172 protected:
173   virtual void CreatePointer(void);
174   virtual void UpdatePointer(void);
175   virtual double getValue () const = 0;
176
177   float radius;
178   float length;
179   float width;
180   float angle;
181   float tape[2];
182   float value1;
183   float value2;
184   float alpha1;
185   float alpha2;
186   float textureXPos;
187   float textureYPos;
188   GLfloat vertices[20];
189 };
190
191
192 /**
193  * Instrument: the airspeed indicator.
194  */
195 class FGAirspeedIndicator : public FGTexInstrument
196 {
197 public:
198   FGAirspeedIndicator (int x, int y);
199   virtual ~FGAirspeedIndicator ();
200
201 protected:
202   double getValue () const;
203 };
204
205
206 /**
207  * Instrument: the vertical speed indicator.
208  */
209 class FGVerticalSpeedIndicator : public FGTexInstrument
210 {
211 public:
212   FGVerticalSpeedIndicator (int x, int y);
213   virtual ~FGVerticalSpeedIndicator ();
214
215 protected:
216   double getValue () const;
217 };
218
219
220 /**
221  * Instrument: the altimeter (big hand?)
222  */
223 class FGAltimeter : public FGTexInstrument
224 {
225 public:
226   FGAltimeter (int x, int y);
227   virtual ~FGAltimeter ();
228
229 protected:
230   double getValue () const;
231 };
232
233
234 /**
235  * Instrument: the altimeter (little hand?)
236  */
237 class FGAltimeter2 : public FGTexInstrument
238 {
239 public:
240   FGAltimeter2 (int x, int y);
241   virtual ~FGAltimeter2 ();
242
243 protected:
244   double getValue () const;
245 };
246
247
248 /**
249  * Instrument: the RPM gauge (actually manifold pressure right now).
250  */
251 class FGRPMIndicator : public FGTexInstrument
252 {
253 public:
254   FGRPMIndicator (int x, int y);
255   virtual ~FGRPMIndicator ();
256
257 protected:
258   double getValue () const;
259 };
260
261
262                                 // FIXME: move to FGPanel, somehow
263 void fgEraseArea(GLfloat *array, int NumVerti, GLfloat texXPos,                                  GLfloat texYPos, GLfloat XPos, GLfloat YPos,                                    int Texid, float ScaleFactor);
264
265 #endif // _PANEL_HXX