]> git.mxchange.org Git - flightgear.git/blob - Simulator/Cockpit/panel.hxx
Merge Tests as subdirectory
[flightgear.git] / Simulator / Cockpit / panel.hxx
1 //  panel.hxx -- instrument panel defines and prototypes
2 // 
3 //  Written by Friedemann Reinhard, started June 1998.
4 // 
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License as
7 //  published by the Free Software Foundation; either version 2 of the
8 //  License, or (at your option) any later version.
9 // 
10 //  This program is distributed in the hope that it will be useful, but
11 //  WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 //  General Public License for more details.
14 // 
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //
19 //  $Id$
20 //  (Log is kept at end of this file)
21  
22 #define LETTER_OFFSET 0.03515625 
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;
45
46 class FGPanel{
47
48 private:
49 int height, width;
50 GLuint FontList;
51
52 GLubyte *background;
53
54 // FGInstrument **instr_list;
55 FGInstrument *test_instr[7];
56
57 void GetData(void);
58
59 public:
60 static FGPanel *OurPanel;
61
62         FGPanel(void);
63
64 float   get_height(void){
65         return height;
66         }
67
68 void    ReInit( int x, int y, int finx, int finy);
69 void    Update(void);
70
71 void    DrawLetter(void){
72         glBegin(GL_POLYGON);
73         glTexCoord2f(0.0, 0.0);
74         glVertex2f(0.0, 0.0);
75         glTexCoord2f(LETTER_OFFSET + 0.004, 0.0);
76         glVertex2f(7.0, 0.0);
77         glTexCoord2f(LETTER_OFFSET + 0.004, 0.0390625);
78         glVertex2f(7.0, 9.0);
79         glTexCoord2f(0.0, 0.0390625);
80         glVertex2f(0.0, 9.0);
81         glEnd();
82         }
83         
84 void DrawTestLetter(float X, float Y);
85 void InitLists(void);
86 void TexString(char *s, float XPos, float YPos, float size);
87
88 };
89
90 class FGInstrument{
91 friend class FGPanel;
92
93 protected:
94 float XPos, YPos;
95
96 public:
97         FGInstrument(void){
98         }
99         
100         virtual ~FGInstrument(void){}
101         
102 virtual void Init(void) = 0;
103 virtual void Render(void) = 0;
104 };
105
106 class FGHorizon : public FGInstrument {
107 private:
108     float texXPos;
109     float texYPos;
110     float radius;
111     float bottom;   // tell the program the offset between midpoint and bottom 
112     float top;      // guess what ;-)
113     float vertices[180][2];
114     float normals[180][3];
115     float texCoord[180][2];
116     
117 public:
118         FGHorizon(void){
119         XPos = 0.0; YPos = 0.0;
120         Init();
121         }
122
123         FGHorizon(float inXPos, float inYPos){
124         XPos = inXPos; YPos = inYPos;
125         Init();
126         }
127         
128 virtual void Init(void);
129 virtual void Render(void);
130
131 };
132
133 class FGTurnCoordinator : public FGInstrument {
134 private:
135     float PlaneTexXPos;
136     float PlaneTexYPos;
137     float alpha;
138     float PlaneAlpha;
139     float alphahist[2];
140     float rollhist[2];
141     float BallXPos;
142     float BallYPos;
143     float BallTexXPos;
144     float BallTexYPos;
145     float BallRadius;
146   GLfloat vertices[72];
147
148 public:
149         FGTurnCoordinator(void){
150         XPos = 0.0; YPos = 0.0;
151         Init();
152         }
153
154         FGTurnCoordinator(float inXPos, float inYPos){
155         XPos = inXPos; YPos = inYPos;
156         Init();
157         }       
158
159 virtual void Init (void);
160 virtual void Render(void);
161
162 };
163
164 class FGRpmGauge : public FGInstrument {
165 private:
166     GLuint list;
167     
168 public:
169         FGRpmGauge(void){
170         XPos = 0.0; YPos = 0.0;
171         Init();
172         }
173
174         FGRpmGauge(float inXPos, float inYPos){
175         XPos = inXPos; YPos = inYPos;
176         Init();
177         }       
178
179 virtual void Init(void);
180 virtual void Render(void);
181 };
182
183 // temporary class until I get the software-only routines for the 
184 // instruments run
185
186 class FGTexInstrument : public FGInstrument {
187
188 private:
189     float radius;
190     float length;
191     float width;
192     float angle;
193     float tape[2];
194     float value1;
195     float value2;
196     float alpha1;
197     float alpha2;
198     float teXpos;
199     float texYpos;
200     int variable;
201     GLfloat vertices[20];
202     
203 public:
204         FGTexInstrument(void){
205         XPos = 0.0; YPos = 0.0;
206         Init();
207         }
208
209         FGTexInstrument(float inXPos, float inYPos, float inradius,                                     float inlength, float inwidth, float inangle,                                   float invalue1, float invalue2, float inalpha1,                                 float inalpha2, float intexXPos, float intexYPos,                               int invariable){
210
211         XPos = inXPos; YPos = inYPos;
212         radius = inradius; angle = inangle;
213         length = inlength; width = inwidth;
214         value1 = invalue1; value2 = invalue2;
215         alpha1 = inalpha1; alpha2 = inalpha2;
216         teXpos = intexXPos; texYpos = intexYPos;
217         variable = invariable; 
218         Init();
219         }
220
221    void CreatePointer(void);
222    void UpdatePointer(void);
223
224    void Init(void);
225    void Render(void);
226 };
227
228 typedef struct{
229 float XPos;
230 float YPos;
231     float radius;
232     float length;
233     float width;
234     float angle;
235     float tape[2];
236     float value1;
237     float value2;
238     float alpha1;
239     float alpha2;
240     float teXpos;
241     float texYpos;
242     int variable;
243     GLfloat vertices[20];
244 }Pointer;
245
246 void fgEraseArea(GLfloat *array, int NumVerti, GLfloat texXPos,                                  GLfloat texYPos, GLfloat XPos, GLfloat YPos,                                    int Texid, float ScaleFactor);
247 void DrawScale(float XPos, float YPos, float InnerRadius, float OuterRadius,                   float alpha1, float alpha2, int steps, float LineWidth,                       float red, float green, float blue, bool filled);
248 void DrawBeechcraftLogo(float XPos, float YPos, float Width, float Height);
249
250 void PrintMatrix( void);
251
252 #endif // _PANEL_HXX 
253
254
255
256 // $Log$
257 // Revision 1.9  1999/03/09 20:58:18  curt
258 // Tweaks for compiling under native Irix compilers.
259 //
260 // Revision 1.8  1999/03/08 21:56:10  curt
261 // Added panel changes sent in by Friedemann.
262 //
263 // Revision 1.5  1999/01/07 19:25:55  curt
264 // Updates from Friedemann Reinhard.
265 //
266 // Revision 1.4  1998/11/11 00:19:29  curt
267 // Updated comment delimeter to C++ style.
268 //
269 // Revision 1.3  1998/11/09 23:38:54  curt
270 // Panel updates from Friedemann.
271 //
272 // Revision 1.2  1998/08/28 18:14:41  curt
273 // Added new cockpit code from Friedemann Reinhard
274 // <mpt218@faupt212.physik.uni-erlangen.de>
275 //
276 // Revision 1.1  1998/06/27 16:47:55  curt
277 // Incorporated Friedemann Reinhard's <mpt218@faupt212.physik.uni-erlangen.de>
278 // first pass at an isntrument panel.
279
280