]> git.mxchange.org Git - flightgear.git/blob - Simulator/Cockpit/panel.hxx
Initial revision.
[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  
21 #define LETTER_OFFSET 0.03515625 
22
23 #ifndef _PANEL_HXX
24 #define _PANEL_HXX
25
26
27 #ifndef __cplusplus                                                          
28 # error This library requires C++
29 #endif                                   
30
31
32 #ifdef HAVE_CONFIG_H
33 #  include <config.h>
34 #endif
35
36 #ifdef HAVE_WINDOWS_H          
37 #  include <windows.h>
38 #endif
39
40 #include <GL/glut.h>
41 #include <XGL/xgl.h>
42
43 class FGInstrument;
44
45 class FGPanel{
46
47 private:
48 int height, width;
49 GLuint FontList;
50
51 GLubyte *background;
52
53 // FGInstrument **instr_list;
54 FGInstrument *test_instr[7];
55
56 void GetData(void);
57
58 public:
59 static FGPanel *OurPanel;
60
61         FGPanel(void);
62
63 float   get_height(void){
64         return height;
65         }
66
67 void    ReInit( int x, int y, int finx, int finy);
68 void    Update(void);
69
70 void    DrawLetter(void){
71         glBegin(GL_POLYGON);
72         glTexCoord2f(0.0, 0.0);
73         glVertex2f(0.0, 0.0);
74         glTexCoord2f(LETTER_OFFSET + 0.004, 0.0);
75         glVertex2f(7.0, 0.0);
76         glTexCoord2f(LETTER_OFFSET + 0.004, 0.0390625);
77         glVertex2f(7.0, 9.0);
78         glTexCoord2f(0.0, 0.0390625);
79         glVertex2f(0.0, 9.0);
80         glEnd();
81         }
82         
83 void DrawTestLetter(float X, float Y);
84 void InitLists(void);
85 void TexString(char *s, float XPos, float YPos, float size);
86
87 };
88
89 class FGInstrument{
90 friend class FGPanel;
91
92 protected:
93 float XPos, YPos;
94
95 public:
96         FGInstrument(void){
97         }
98         
99         virtual ~FGInstrument(void){}
100         
101 virtual void Init(void) = 0;
102 virtual void Render(void) = 0;
103 };
104
105 class FGHorizon : public FGInstrument {
106 private:
107     float texXPos;
108     float texYPos;
109     float radius;
110     float bottom;   // tell the program the offset between midpoint and bottom 
111     float top;      // guess what ;-)
112     float vertices[180][2];
113     float normals[180][3];
114     float texCoord[180][2];
115     
116 public:
117         FGHorizon(void){
118         XPos = 0.0; YPos = 0.0;
119         Init();
120         }
121
122         FGHorizon(float inXPos, float inYPos){
123         XPos = inXPos; YPos = inYPos;
124         Init();
125         }
126         
127 virtual void Init(void);
128 virtual void Render(void);
129
130 };
131
132 class FGTurnCoordinator : public FGInstrument {
133 private:
134     float PlaneTexXPos;
135     float PlaneTexYPos;
136     float alpha;
137     float PlaneAlpha;
138     float alphahist[2];
139     float rollhist[2];
140     float BallXPos;
141     float BallYPos;
142     float BallTexXPos;
143     float BallTexYPos;
144     float BallRadius;
145   GLfloat vertices[72];
146
147 public:
148         FGTurnCoordinator(void){
149         XPos = 0.0; YPos = 0.0;
150         Init();
151         }
152
153         FGTurnCoordinator(float inXPos, float inYPos){
154         XPos = inXPos; YPos = inYPos;
155         Init();
156         }       
157
158 virtual void Init (void);
159 virtual void Render(void);
160
161 };
162
163 class FGRpmGauge : public FGInstrument {
164 private:
165     GLuint list;
166     
167 public:
168         FGRpmGauge(void){
169         XPos = 0.0; YPos = 0.0;
170         Init();
171         }
172
173         FGRpmGauge(float inXPos, float inYPos){
174         XPos = inXPos; YPos = inYPos;
175         Init();
176         }       
177
178 virtual void Init(void);
179 virtual void Render(void);
180 };
181
182 // temporary class until I get the software-only routines for the 
183 // instruments run
184
185 class FGTexInstrument : public FGInstrument {
186
187 private:
188     float radius;
189     float length;
190     float width;
191     float angle;
192     float tape[2];
193     float value1;
194     float value2;
195     float alpha1;
196     float alpha2;
197     float teXpos;
198     float texYpos;
199     int variable;
200     GLfloat vertices[20];
201     
202 public:
203         FGTexInstrument(void){
204         XPos = 0.0; YPos = 0.0;
205         Init();
206         }
207
208         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){
209
210         XPos = inXPos; YPos = inYPos;
211         radius = inradius; angle = inangle;
212         length = inlength; width = inwidth;
213         value1 = invalue1; value2 = invalue2;
214         alpha1 = inalpha1; alpha2 = inalpha2;
215         teXpos = intexXPos; texYpos = intexYPos;
216         variable = invariable; 
217         Init();
218         }
219
220    void CreatePointer(void);
221    void UpdatePointer(void);
222
223    void Init(void);
224    void Render(void);
225 };
226
227 typedef struct{
228 float XPos;
229 float YPos;
230     float radius;
231     float length;
232     float width;
233     float angle;
234     float tape[2];
235     float value1;
236     float value2;
237     float alpha1;
238     float alpha2;
239     float teXpos;
240     float texYpos;
241     int variable;
242     GLfloat vertices[20];
243 }Pointer;
244
245 void fgEraseArea(GLfloat *array, int NumVerti, GLfloat texXPos,                                  GLfloat texYPos, GLfloat XPos, GLfloat YPos,                                    int Texid, float ScaleFactor);
246 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);
247 void DrawBeechcraftLogo(float XPos, float YPos, float Width, float Height);
248
249 void PrintMatrix( void);
250
251 #endif // _PANEL_HXX 
252
253
254