]> git.mxchange.org Git - flightgear.git/blob - Cockpit/cockpit.c
Code reorganizations. Added a Lib/ directory for more general libraries.
[flightgear.git] / Cockpit / cockpit.c
1 /**************************************************************************
2  * cockpit.c -- routines to draw a cockpit (initial draft)
3  *
4  * Written by Michele America, started September 1997.
5  *
6  * Copyright (C) 1997  Michele F. America  - nomimarketing@mail.telepac.pt
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * $Id$
23  * (Log is kept at end of this file)
24  **************************************************************************/
25
26
27 #include <config.h>
28
29 #ifdef HAVE_WINDOWS_H          
30 #  include <windows.h>
31 #endif
32
33 #include <GL/glut.h>
34
35 #include <stdlib.h>
36 #include <Cockpit/cockpit.h>
37
38 #include <Include/fg_constants.h>
39
40 #include <Aircraft/aircraft.h>
41 #include <Scenery/scenery.h>
42 #include <Math/mat3.h>
43 #include <Math/polar.h>
44 #include <Time/fg_timer.h>
45 #include <Math/fg_random.h>
46 #include <Weather/weather.h>
47
48 #include <Main/fg_debug.h>
49
50 // This is a structure that contains all data related to
51 // cockpit/panel/hud system
52
53 static fgCOCKPIT *aircraft_cockpit;
54
55 fgCOCKPIT *fgCockpitInit( fgAIRCRAFT *cur_aircraft )
56 {
57         fgCOCKPIT *cockpit;
58         Hptr hud;
59
60         fgPrintf( FG_COCKPIT, FG_INFO, "Initializing cockpit subsystem\n");
61
62         cockpit = (fgCOCKPIT *)calloc(sizeof(fgCOCKPIT),1);
63         if( cockpit == NULL )
64                 return( NULL );
65
66         cockpit->code = 1;      /* It will be aircraft dependent */
67         cockpit->status = 0;
68
69         // If aircraft has HUD
70         hud = fgHUDInit( cur_aircraft );  // Color no longer in parameter list
71         if( hud == NULL )
72                 return( NULL );
73
74         cockpit->hud = hud;
75
76         aircraft_cockpit = cockpit;
77
78         fgPrintf( FG_COCKPIT, FG_INFO,
79                   "  Code %d  Status %d\n", 
80                   cockpit->hud->code, cockpit->hud->status );
81
82         return( cockpit );
83 }
84
85 fgCOCKPIT *fgCockpitAddHUD( fgCOCKPIT *cockpit, HUD *hud )
86 {
87         cockpit->hud = hud;
88         return(cockpit);
89 }
90
91 void fgCockpitUpdate( void )
92 {
93
94         fgPrintf( FG_COCKPIT, FG_DEBUG,
95                   "Cockpit: code %d   status %d\n", 
96                   aircraft_cockpit->code, aircraft_cockpit->status );
97         if( aircraft_cockpit->hud != NULL ) {
98             // That is, if the aircraft has a HUD, then draw it.
99             fgUpdateHUD( aircraft_cockpit->hud );
100         }
101 }
102
103
104 /* $Log$
105 /* Revision 1.12  1998/04/14 02:23:09  curt
106 /* Code reorganizations.  Added a Lib/ directory for more general libraries.
107 /*
108  * Revision 1.11  1998/03/14 00:32:13  curt
109  * Changed a printf() to a fgPrintf().
110  *
111  * Revision 1.10  1998/02/07 15:29:33  curt
112  * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
113  * <chotchkiss@namg.us.anritsu.com>
114  *
115  * Revision 1.9  1998/02/03 23:20:14  curt
116  * Lots of little tweaks to fix various consistency problems discovered by
117  * Solaris' CC.  Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
118  * passed arguments along to the real printf().  Also incorporated HUD changes
119  * by Michele America.
120  *
121  * Revision 1.8  1998/01/31 00:43:03  curt
122  * Added MetroWorks patches from Carmen Volpe.
123  *
124  * Revision 1.7  1998/01/27 00:47:51  curt
125  * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
126  * system and commandline/config file processing code.
127  *
128  * Revision 1.6  1998/01/19 19:27:01  curt
129  * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
130  * This should simplify things tremendously.
131  *
132  * Revision 1.5  1998/01/19 18:40:19  curt
133  * Tons of little changes to clean up the code and to remove fatal errors
134  * when building with the c++ compiler.
135  *
136  * Revision 1.4  1997/12/30 20:47:34  curt
137  * Integrated new event manager with subsystem initializations.
138  *
139  * Revision 1.3  1997/12/15 23:54:33  curt
140  * Add xgl wrappers for debugging.
141  * Generate terrain normals on the fly.
142  *
143  * Revision 1.2  1997/12/10 22:37:38  curt
144  * Prepended "fg" on the name of all global structures that didn't have it yet.
145  * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
146  *
147  * Revision 1.1  1997/08/29 18:03:20  curt
148  * Initial revision.
149  *
150  */