void fgAircraftInit( void ) {
fgPrintf( FG_AIRCRAFT, FG_INFO, "Initializing Aircraft structure\n" );
- current_aircraft.flight = &cur_flight_params;
+ current_aircraft.flight = &cur_flight_params;
current_aircraft.controls = &cur_control_params;
}
/* $Log$
-/* Revision 1.16 1998/02/07 15:29:31 curt
-/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+/* Revision 1.17 1998/02/12 21:59:31 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.16 1998/02/07 15:29:31 curt
+ * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
* Revision 1.15 1998/01/27 00:47:46 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
}
+// This function assumes that if the FILE ptr is valid that the contents
+// will be valid. Should we check the file for validity?
void fgReadOrbElements(struct OrbElements *dest, FILE *src)
{
}
while (!(strlen(line)));
sscanf(line, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n",
- &dest->NFirst, &dest->NSec,
- &dest->iFirst, &dest->iSec,
- &dest->wFirst, &dest->wSec,
- &dest->aFirst, &dest->aSec,
- &dest->eFirst, &dest->eSec,
- &dest->MFirst, &dest->MSec);
+ &dest->NFirst, &dest->NSec,
+ &dest->iFirst, &dest->iSec,
+ &dest->wFirst, &dest->wSec,
+ &dest->aFirst, &dest->aSec,
+ &dest->eFirst, &dest->eSec,
+ &dest->MFirst, &dest->MSec);
}
-void fgSolarSystemInit(struct fgTIME t)
+int fgSolarSystemInit(struct fgTIME t)
{
- struct fgGENERAL *g;
- char path[80];
- int i;
- FILE *data;
+ struct fgGENERAL *g;
+ char path[80];
+ int i;
+ FILE *data;
+ int ret_val = 0;
- fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
+ fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
/* build the full path name to the orbital elements database file */
- g = &general;
- path[0] = '\0';
- strcat(path, g->root_dir);
- strcat(path, "/Scenery/");
- strcat(path, "Planets.dat");
-
- if ( (data = fopen(path, "r")) == NULL )
- {
- fgPrintf( FG_ASTRO, FG_ALERT,
- "Cannot open data file: '%s'\n", path);
- return;
- }
- /* printf(" reading datafile %s\n", path); */
- fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path);
-
- /* for all the objects... */
- for (i = 0; i < 9; i ++)
- {
- /* ...read from the data file ... */
- fgReadOrbElements(&pltOrbElements[i], data);
- /* ...and calculate the actual values */
- fgSolarSystemUpdate(&pltOrbElements[i], t);
- }
+ g = &general;
+ path[0] = '\0';
+ strcat(path, g->root_dir);
+ strcat(path, "/Scenery/");
+ strcat(path, "Planets.dat");
+ if ( (data = fopen(path, "r")) == NULL )
+ {
+ fgPrintf( FG_ASTRO, FG_ALERT,
+ "Cannot open data file: '%s'\n", path);
+ } else {
+ /* printf(" reading datafile %s\n", path); */
+ fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path);
+
+ /* for all the objects... */
+ for (i = 0; i < 9; i ++)
+ {
+ /* ...read from the data file ... */
+ fgReadOrbElements(&pltOrbElements[i], data);
+ /* ...and calculate the actual values */
+ fgSolarSystemUpdate(&pltOrbElements[i], t);
+ }
+ ret_val = 1;
+ }
+ return ret_val;
}
/* $Log$
-/* Revision 1.6 1998/02/03 23:20:11 curt
-/* Lots of little tweaks to fix various consistency problems discovered by
-/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
-/* passed arguments along to the real printf(). Also incorporated HUD changes
-/* by Michele America.
+/* Revision 1.7 1998/02/12 21:59:33 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.6 1998/02/03 23:20:11 curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf(). Also incorporated HUD changes
+ * by Michele America.
+ *
* Revision 1.5 1998/02/02 20:53:22 curt
* To version 0.29
*
double fgCalcActTime(struct fgTIME t);
void fgReadOrbElements(struct OrbElements *dest, FILE *src);
-void fgSolarSystemInit(struct fgTIME t);
+int fgSolarSystemInit(struct fgTIME t);
void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
/* $Log$
-/* Revision 1.4 1998/02/02 20:53:22 curt
-/* To version 0.29
+/* Revision 1.5 1998/02/12 21:59:35 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.4 1998/02/02 20:53:22 curt
+ * To version 0.29
+ *
* Revision 1.3 1998/01/22 02:59:27 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*
fgPrintf( FG_ASTRO, FG_ALERT, "index %d out of range !!!!\n", idx);
}
fgPrintf( FG_ASTRO, FG_DEBUG,
- " Planet found at %f (ra), %f (dec)\n",
+ " Planet found at %f (ra), %f (dec)\n",
result.RightAscension, result.Declination);
fgPrintf( FG_ASTRO, FG_DEBUG,
" Geocentric dist %f\n"
xglVertex3f( 50000.0 * cos(pltPos.RightAscension) *
cos(pltPos.Declination),
- 50000.0 * sin(pltPos.RightAscension) *
+ 50000.0 * sin(pltPos.RightAscension) *
cos(pltPos.Declination),
50000.0 * sin(pltPos.Declination) );
}
/* $Log$
-/* Revision 1.5 1998/02/03 23:20:12 curt
-/* Lots of little tweaks to fix various consistency problems discovered by
-/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
-/* passed arguments along to the real printf(). Also incorporated HUD changes
-/* by Michele America.
+/* Revision 1.6 1998/02/12 21:59:36 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.5 1998/02/03 23:20:12 curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf(). Also incorporated HUD changes
+ * by Michele America.
+ *
* Revision 1.4 1998/02/02 20:53:23 curt
* To version 0.29
*
struct fgTIME t, int idx);
-void fgPlanetsInit();
-void fgPlanetsRender();
+void fgPlanetsInit( void );
+void fgPlanetsRender( void );
#endif /* PLANETS_H */
/* $Log$
-/* Revision 1.3 1998/02/02 20:53:23 curt
-/* To version 0.29
+/* Revision 1.4 1998/02/12 21:59:38 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.3 1998/02/02 20:53:23 curt
+ * To version 0.29
+ *
* Revision 1.2 1998/01/22 02:59:28 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*
/* Initialize the Star Management Subsystem */
-void fgStarsInit( void ) {
+int fgStarsInit( void ) {
FILE *fd;
struct fgGENERAL *g;
/* struct CelestialCoord pltPos; */
max_stars = FG_MAX_STARS;
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
- fgPrintf( FG_ASTRO, FG_INFO,
+ fgPrintf( FG_ASTRO, FG_INFO,
" Loading %d Stars: %s\n", max_stars, path);
if ( (fd = fopen(path, "r")) == NULL ) {
- fgPrintf( FG_ASTRO, FG_ALERT,
+ fgPrintf( FG_ASTRO, FG_ALERT,
"Cannot open star file: '%s'\n", path);
- return;
+ return 0; // Oops, lets not even try to continue. This is critical.
}
-
+
stars[i] = xglGenLists(1);
xglNewList( stars[i], GL_COMPILE );
xglBegin( GL_POINTS );
/* blank line */
} else {
/* star data line */
-
+
/* get name */
end = front;
while ( end[0] != ',' ) {
front = end;
front++;
- sscanf(front, "%lf,%lf,%lf\n",
+ sscanf(front, "%lf,%lf,%lf\n",
&right_ascension, &declination, &magnitude);
/*
- if ( strcmp(name, "Betelgeuse") == 0 ) {
- printf(" *** Marking %s\n", name);
- ra_save = right_ascension;
- decl_save = declination;
- }
- */
+ if ( strcmp(name, "Betelgeuse") == 0 ) {
+ printf(" *** Marking %s\n", name);
+ ra_save = right_ascension;
+ decl_save = declination;
+ }
+ */
/*
- if ( strcmp(name, "Alnilam") == 0 ) {
- printf(" *** Marking %s\n", name);
- ra_save1 = right_ascension;
- decl_save1 = declination;
- }
- */
+ if ( strcmp(name, "Alnilam") == 0 ) {
+ printf(" *** Marking %s\n", name);
+ ra_save1 = right_ascension;
+ decl_save1 = declination;
+ }
+ */
/* scale magnitudes to (0.0 - 1.0) */
magnitude = (0.0 - magnitude) / 5.0 + 1.0;
/* scale magnitudes again so they look ok */
if ( magnitude > 1.0 ) { magnitude = 1.0; }
if ( magnitude < 0.0 ) { magnitude = 0.0; }
- magnitude =
+ magnitude =
magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1);
/* printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
- name, right_ascension, declination, magnitude); */
+ name, right_ascension, declination, magnitude); */
xglColor3f( magnitude, magnitude, magnitude );
/*xglColor3f(0,0,0);*/
xglVertex3f( 50000.0 * cos(right_ascension) * cos(declination),
50000.0 * sin(right_ascension) * cos(declination),
50000.0 * sin(declination) );
-
+
count++;
- } /* if valid line */
+ } // valid line
} /* while */
50000.0 * sin(decl_save1+0.2) );
xglEnd();
*/
-
+
xglEndList();
max_stars /= 2;
}
+
+ return 1; // OK, we got here because initialization worked.
}
/* $Log$
-/* Revision 1.7 1998/02/09 15:07:48 curt
-/* Minor tweaks.
+/* Revision 1.8 1998/02/12 21:59:38 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.7 1998/02/09 15:07:48 curt
+ * Minor tweaks.
+ *
* Revision 1.6 1998/02/02 20:53:23 curt
* To version 0.29
*
#define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */
/* Initialize the Star Management Subsystem */
-void fgStarsInit( void );
+int fgStarsInit( void );
/* Draw the Stars */
void fgStarsRender( void );
/* $Log$
-/* Revision 1.3 1998/01/22 02:59:28 curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.4 1998/02/12 21:59:39 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.3 1998/01/22 02:59:28 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
* Revision 1.2 1998/01/19 18:40:18 curt
* Tons of little changes to clean up the code and to remove fatal errors
* when building with the c++ compiler.
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
- fgPrintf( FG_ASTRO, FG_INFO,
- "Sun found at %f (ra), %f (dec)\n",
+
+ fgPrintf( FG_ASTRO, FG_INFO,
+ "Sun found at %f (ra), %f (dec)\n",
sunPos.RightAscension, sunPos.Declination);
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
if (amb[1] > 1.0) amb[1] = 1.0;
if (amb[2] > 1.0) amb[2] = 1.0;
- fgPrintf( FG_ASTRO, FG_DEBUG,
- "Color of the sun: %f, %f, %f\n"
- "Ambient value : %f\n"
- "Sun Angle : %f\n" ,
- amb[0], amb[1], amb[2], ambient, l->sun_angle);
-
+ fgPrintf( FG_ASTRO, FG_DEBUG,
+ "Color of the sun: %f, %f, %f\n"
+ "Ambient value : %f\n"
+ "Sun Angle : %f\n" ,
+ amb[0], amb[1], amb[2], ambient, l->sun_angle);
+
/* set lighting parameters */
/*xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, color );
/* $Log$
-/* Revision 1.5 1998/02/02 20:53:24 curt
-/* To version 0.29
+/* Revision 1.6 1998/02/12 21:59:39 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.5 1998/02/02 20:53:24 curt
+ * To version 0.29
+ *
* Revision 1.4 1998/01/27 00:47:50 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
#include <string.h>
#ifndef WIN32
-# include <values.h> /* for MAXINT */
-#endif /* not WIN32 */
+# include <values.h> // for MAXINT
+#endif //
#include "hud.h"
#include <Math/mat3.h>
#include <Math/polar.h>
#include <Scenery/scenery.h>
-// #include <Scenery/mesh.h> /* not used any more :-) */
#include <Time/fg_timer.h>
#include <Weather/weather.h>
factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units;
- for( i=vmin; i<=vmax; i+=1 )
+ for( i = vmin; i <= vmax; i++ )
{
- if( pscale->sub_type == LIMIT )
- condition = i>= pscale->minimum_value;
- else
- if( pscale->sub_type == NOLIMIT )
+ if( pscale->sub_type == LIMIT ) {
+ condition = (i >= pscale->minimum_value);
+ }
+ else {
+ if( pscale->sub_type == NOLIMIT ) {
condition = 1;
-
+ }
+ }
if( condition )
{
- marker_y = pscale->scr_min+(i-vmin)*factor;
- if( i%pscale->div_min==0 )
+ marker_y = pscale->scr_min + (i - vmin) * factor;
+ if( !(i%pscale->div_min)) {
if( pscale->orientation == LEFT )
{
- drawOneLine( marker_x+3, marker_y, marker_x+6, marker_y );
+ drawOneLine( marker_x + 3, marker_y, marker_x + 6, marker_y );
}
- else
+ else {
if( pscale->orientation == RIGHT )
{
- drawOneLine( marker_x, marker_y, marker_x+3, marker_y );
+ drawOneLine( marker_x, marker_y, marker_x + 3, marker_y );
}
if( i%pscale->div_max==0 )
{
- drawOneLine( marker_x, marker_y, marker_x+6, marker_y );
+ drawOneLine( marker_x, marker_y, marker_x + 6, marker_y );
sprintf( TextScale, "%d", i );
if( pscale->orientation == LEFT )
{
- textString( marker_x-8*strlen(TextScale)-2, marker_y-4,
+ textString( marker_x - 8 * strlen(TextScale) - 2, marker_y - 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
- else
+ else {
if( pscale->orientation == RIGHT )
{
textString( marker_x+10, marker_y-4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
+ }
}
- }
+ }
+ }
+ }
} // End for range of i from vmin to vmax
}
if( pscale->type == HORIZONTAL ) // Horizontal scale
{
- if( pscale->orientation == TOP )
+ if( pscale->orientation == TOP ) {
marker_y = pscale->scr_pos;
- else
- if( pscale->orientation == BOTTOM )
- marker_y = pscale->scr_pos-6;
+ }
+ else {
+ if( pscale->orientation == BOTTOM ) {
+ marker_y = pscale->scr_pos - 6;
+ }
+ }
drawOneLine( pscale->scr_min,
pscale->scr_pos,
pscale->scr_max,
pscale->scr_pos-6 );
}
- else
+ else {
if( pscale->orientation == BOTTOM )
{
drawOneLine( pscale->scr_min,
mid_scr,
pscale->scr_pos+6 );
}
-
+ }
factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units;
- for( i=vmin; i<=vmax; i+=1 )
+ for( i = vmin; i <= vmax; i++ ) // increment is faster than addition
{
- if( pscale->sub_type == LIMIT )
- condition = i>= pscale->minimum_value;
- else
- if( pscale->sub_type == NOLIMIT )
+ if( pscale->sub_type == LIMIT ) {
+ condition = (i >= pscale->minimum_value);
+ }
+ else {
+ if( pscale->sub_type == NOLIMIT ) {
condition = 1;
-
+ }
+ }
if( condition )
{
marker_x = pscale->scr_min+(i-vmin)*factor;
- if( i%pscale->div_min==0 )
+ if( i%pscale->div_min==0 ) {
if( pscale->orientation == TOP )
{
drawOneLine( marker_x, marker_y, marker_x, marker_y+3 );
}
- else
+ else {
if( pscale->orientation == BOTTOM )
{
drawOneLine( marker_x, marker_y+3, marker_x, marker_y+6 );
}
- if( i%pscale->div_max==0 )
+ }
+ }
+ if( i%pscale->div_max==0 )
+ {
+ sprintf( TextScale, "%d", i );
+ if( pscale->orientation == TOP )
{
- sprintf( TextScale, "%d", i );
- if( pscale->orientation == TOP )
+ drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
+ textString ( marker_x-4*strlen(TextScale), marker_y+14,
+ TextScale, GLUT_BITMAP_8_BY_13 );
+ }
+ else {
+ if( pscale->orientation == BOTTOM )
{
drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
- textString ( marker_x-4*strlen(TextScale), marker_y+14,
+ textString ( marker_x+10, marker_y-4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
- else
- if( pscale->orientation == BOTTOM )
- {
- drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
- textString ( marker_x+10, marker_y-4,
- TextScale, GLUT_BITMAP_8_BY_13 );
- }
}
+ }
}
}
}
}
-/*
-
- Draws a climb ladder in the center of the HUD
-
-*/
+//
+// Draws a climb ladder in the center of the HUD
+//
static void drawladder( HUD_ladder *ladder )
{
vmin = pitch_value - ladder->width_units/2;
vmax = pitch_value + ladder->width_units/2;
-
+
scr_min = ladder->y_pos - (ladder->scr_height/2);
scr_max = scr_min + ladder->scr_height;
sprintf( TextLadder, "%d", i );
if( ladder->scr_hole == 0 )
{
- if( i )
+ if( i ) {
x_ini = ladder->x_pos - ladder->scr_width/2;
- else
+ }
+ else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
+ }
y_ini = marker_y;
x_end = ladder->x_pos + ladder->scr_width/2;
y_end = marker_y;
}
else
{
- if( i != 0 )
+ if( i != 0 ) {
x_ini = ladder->x_pos - ladder->scr_width/2;
- else
+ }
+ else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
+ }
y_ini = marker_y;
x_end = ladder->x_pos - ladder->scr_width/2 + ladder->scr_hole/2;
y_end = marker_y;
x_ini = ladder->x_pos + ladder->scr_width/2 - ladder->scr_hole/2;
y_ini = marker_y;
- if( i != 0 )
+ if( i != 0 ) {
x_end = ladder->x_pos + ladder->scr_width/2;
- else
+ }
+ else {
x_end = ladder->x_pos + ladder->scr_width/2 + 10;
+ }
y_end = marker_y;
new_x_ini = ladder->x_pos + \
(x_ini-ladder->x_pos)*cos(roll_value) -\
horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 );
}
}
-/*
- Draws a representation of the control surfaces in their current state
- anywhere in the HUD
-
- Needs: struct HUD_control_surfaces
+// drawControlSurfaces()
+// Draws a representation of the control surfaces in their current state
+// anywhere in the HUD
+//
-*/
static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf )
{
int x_ini, y_ini;
drawOneLine( x_ini + 35 + (int)(((FG_Rudder + 1.0)/2)*50.0), y_ini + 25, \
x_ini + 35 + (int)(((FG_Rudder + 1.0)/2)*50.0), y_ini + 5 );
}
-
-
+
+
/* Draw throttle diagram */
- textString( x_ini + 90 + 1, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
- textString( x_ini + 90 + 1, y_end-21, "r", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 90 + 1, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 90 + 1, y_end-21, "r", GLUT_BITMAP_8_BY_13 );
drawOneLine( x_ini + 105, y_ini + 5, x_ini + 105, y_ini + 55 );
drawOneLine( x_ini + 100, y_ini + 5 + (int)(FG_Throttle[0]*50.0), \
x_ini + 110, y_ini + 5 + (int)(FG_Throttle[0]*50.0) );
-
-
+
+
/* Draw elevator trim diagram */
- textString( x_ini + 121, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
- textString( x_ini + 121, y_end-22, "m", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 121, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 121, y_end-22, "m", GLUT_BITMAP_8_BY_13 );
drawOneLine( x_ini + 135, y_ini + 5, x_ini + 135, y_ini + 55 );
drawOneLine( x_ini + 134, y_ini + 30, x_ini + 136, y_ini + 30 );
if( FG_Elev_Trim <= -0.01 || FG_Elev_Trim >= 0.01 )
drawOneLine( x_ini + 127, y_ini + 5 + (int)(((FG_Elev_Trim + 1.0)/2)*50.0), \
x_ini + 143, y_ini + 5 + (int)(((FG_Elev_Trim + 1.0)/2)*50.0) );
}
-
+
}
//
sprintf( string, buffer, (*label->load_value)() );
-
+#ifdef DEBUGHUD
fgPrintf( FG_COCKPIT, FG_DEBUG, buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, string );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
-
+#endif
lenstr = strlen( string );
if( label->justify == LEFT_JUST ) {
posincr = -lenstr*8;
hud->code = 1;
hud->status = 0;
- // For now lets just hardcode the hud here .
+ // For now lets just hardcode the hud here.
// In the future, hud information has to come from the same place
// aircraft information came from.
RIGHT_JUST, NULL, " m", "%5.0f", get_altitude );
fgHUDAddLadder ( hud, 330, 190, 90, 180, 70, 10,
NONE, 45, get_roll, get_pitch );
- // fgHUDAddControlSurfaces( hud, 10, 10, get_heading );
+ fgHUDAddControlSurfaces( hud, 10, 10, get_heading );
return( hud );
}
return hud;
}
+// fgHUDAddControlSurfaces()
+//
+// Adds the control surface indicators which make up for the lack of seat
+// of the pants feel. Should be unnecessary with joystick and pedals
+// enabled. But that is another improvement. Also, what of flaps? Spoilers?
+// This may need to be expanded or flattened into multiple indicators,
+// vertical and horizontal.
+
+Hptr fgHUDAddControlSurfaces( Hptr hud,
+ int x_pos,
+ int y_pos,
+ double (*load_value)() )
+{
+ HUD_control_surfaces *pctrl_surf;
+ HUD_instr *pinstrument;
+
+ if( !hud ) {
+ return NULL;
+ }
+
+ // Construct shell
+ pinstrument = (HIptr)calloc(sizeof(HUD_instr),1);
+ if( !pinstrument )
+ return NULL;
+
+ pinstrument->type = HUDcontrols;
+
+ // Construct core
+ pctrl_surf = (HUD_control_surfaces *)calloc(sizeof(HUD_control_surfaces),1);
+ if( !(pctrl_surf == NULL) )
+ return( NULL );
+
+ pctrl_surf->x_pos = x_pos;
+ pctrl_surf->y_pos = y_pos;
+ pctrl_surf->load_value = load_value;
+ // Integrate
+ pinstrument->instr = pctrl_surf;
+ // Install
+ add_instrument( hud, pinstrument);
+
+ return hud;
+}
+
+
/*
Hptr fgHUDAddMovingHorizon( Hptr hud, \
int x_pos, \
glLineWidth(1);
glColor3f (0.1, 0.9, 0.1);
- fgPrintf( FG_COCKPIT, FG_DEBUG,
- "HUD Code %d Status %d\n",
- hud->code, hud->status );
+ fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
+ hud->code, hud->status );
phud_instr = hud->instruments;
while( phud_instr ) {
case HUDcontrols:
drawControlSurfaces( (pHUDControlSurface) phud_instr->instr );
+ break;
default:; // Ignore anything you don't know about.
}
/* $Log$
-/* Revision 1.13 1998/02/11 02:50:19 curt
-/* Added changes submitted by Michele America.
+/* Revision 1.14 1998/02/12 21:59:41 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
* Revision 1.12 1998/02/09 15:07:48 curt
* Minor tweaks.
#include <Flight/flight.h>
#include <Controls/controls.h>
+// View mode definitions
-/* Instrument types */
+enum VIEW_MODES { HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
+
+// Instrument types
#define ARTIFICIAL_HORIZON 1
#define SCALE 2
#define LADDER 3
#define LABEL 4
-/* Scale constants */
+// Scale constants
#define HORIZONTAL 1
#define TOP 2
#define BOTTOM 3
#define NOLIMIT 8
#define ROUNDROB 9
-/* Label constants */
+// Label constants
#define SMALL 1
#define LARGE 2
#define BLINK 3
#define CENTER_JUST 6
#define RIGHT_JUST 7
-/* Ladder constants */
+// Ladder constants
#define NONE 1
#define UPPER_LEFT 2
#define UPPER_CENTER 3
#define DASHED_LINES 11
#define DASHED_NEG_LINES 12
-/* Ladder orientaion */
+// Ladder orientaion
// #define HUD_VERTICAL 1
// #define HUD_HORIZONTAL 2
// #define HUD_FREEFLOAT 3
-/* Ladder orientation modes */
+// Ladder orientation modes
// #define HUD_LEFT 1
// #define HUD_RIGHT 2
// #define HUD_TOP 1
// #define HUD_H_BOTTOM 2
-/* Ladder sub-types */
+// Ladder sub-types
// #define HUD_LIM 1
// #define HUD_NOLIM 2
// #define HUD_CIRC 3
// Removed union HUD_instr_data to evolve this to oop code.
-enum hudinstypes { HUDno_instr,
+typedef enum{ HUDno_instr,
HUDscale,
HUDcirc_scale,
HUDladder,
HUDhorizon,
HUDlabel,
HUDcontrols
- };
+ } hudinstype;
typedef struct HUD_INSTR_STRUCT{
- int type;
+ hudinstype type;
int sub_type;
int orientation;
void *instr; // For now we will cast this pointer accoring to the value
void fgUpdateHUD2( Hptr hud ); // Future use?
-#endif /* _HUD_H */
-
+#endif // _HUD_H
/* $Log$
-/* Revision 1.9 1998/02/11 02:50:22 curt
-/* Added changes submitted by Michele America.
+/* Revision 1.10 1998/02/12 21:59:42 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
* Revision 1.8 1998/02/07 15:29:35 curt
* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
return( joystick_fd );
#else
- return( 0 );
+ return( 1 );
#endif
}
/* $Log$
-/* Revision 1.4 1998/02/03 23:20:20 curt
-/* Lots of little tweaks to fix various consistency problems discovered by
-/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
-/* passed arguments along to the real printf(). Also incorporated HUD changes
-/* by Michele America.
+/* Revision 1.5 1998/02/12 21:59:44 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.4 1998/02/03 23:20:20 curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf(). Also incorporated HUD changes
+ * by Michele America.
+ *
* Revision 1.3 1998/01/27 00:47:54 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
#define _GLUTKEY_H
-#ifdef GLUT
- #include <GL/glut.h>
-#elif TIGER
- /* assumes -I/usr/include/mesa in compile command */
- #include "gltk.h"
+#ifdef WIN32
+# include <windows.h>
#endif
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
/* Handle keyboard events */
void GLUTkey(unsigned char k, int x, int y);
void GLUTspecialkey(int k, int x, int y);
/* $Log$
-/* Revision 1.6 1998/01/22 02:59:36 curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.7 1998/02/12 21:59:44 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.6 1998/01/22 02:59:36 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
* Revision 1.5 1997/07/23 21:52:23 curt
* Put comments around the text after an #endif for increased portability.
*
#include <XGL/xgl.h>
#include <stdio.h>
+#include <getopt.h>
#include <Main/GLUTkey.h>
#include <Main/fg_init.h>
#include <Main/fg_debug.h>
+#include <Main/fg_getopt.h>
#include <Main/views.h>
+#include <Include/cmdargs.h> // Line to command line arguments
#include <Include/fg_constants.h>
#include <Include/general.h>
/* Yet another other hack. Used for my prototype instrument code. (Durk) */
int displayInstruments;
-
+// The following defines flight gear options. Because glutlib will also
+// want to parse its own options, those options must not be included here
+// or they will get parsed by the main program option parser. Hence case
+// is significant for any option added that might be in conflict with
+// glutlib's parser.
+//
+// glutlib parses for:
+// -display
+// -direct (invalid in Win32)
+// -geometry
+// -gldebug
+// -iconized
+// -indirect (invalid in Win32)
+// -synce
+//
+// Note that glutlib depends upon strings while this program's
+// option parser wants only initial characters followed by numbers
+// or pathnames.
+//
+const char *fg_cmdargopts = "a:c:Hhp:r:v:x:?";
+//
+// Where
+// -a aircraftfilename aircraft start over ride
+// -c0x0000 - 0xffffffff debug class setting
+// H,h.? help on command line use (does not need Option struct)
+// -p priority
+// -r flightgear root path to program support files
+// -v0 -v1 initial view mode (hud/no_hud currently)
+// -xlogpathname debug logfile name
+//
+// Defaults in arguments to indicate not set on command line.
+// Program defaults set variables from constants if neither command
+// options or environmental variables effect values.
+//
+
+char acArgbuf [ MAXPATH + 1] = "\0";
+int debugArgValue = -2;
+int priorityArgValue = -1;
+char rootArgbuf [ MAXPATH + 1] = "\0";
+int viewArg = -1;
+char logArgbuf [ MAXPATH + 1] = "\0";
+
+// There is a reason for defining the option structs by name and then
+// creating an array of pointers to options. C++ is unfriendly to
+// initializing arrays of objects that are not built in types. Always
+// look forward. (Besides, you can follow what is going on better and
+// add or modify with greater security. -ch
+//
+Option aircraftOption = { 'a',
+ OPT_STRING,
+ acArgbuf,
+ "Startup aircraft pathname override"
+ };
+Option debugOption = { 'c',
+ OPT_LHEX, // Long int (32 bits)
+ &debugArgValue,
+ "Debug trace level"
+ };
+Option priorityOption = { 'p',
+ OPT_INTEGER,
+ &priorityArgValue,
+ "Debug priority Threshold"
+ };
+Option rootOption = { 'r',
+ OPT_STRING,
+ rootArgbuf,
+ "Root directory for execution"
+ };
+Option hudOption = { 'v',
+ OPT_SWITCH,
+ &viewArg,
+ "View mode start" // HUD,Panel,Chase,Tower
+ };
+Option logfileOption = { 'x',
+ OPT_STRING,
+ logArgbuf,
+ "Debug log file name"
+ };
+
+//
+#define OptsDefined 6
+Option *CmdLineOptions[ OptsDefined ] = {
+ &aircraftOption,
+ &debugOption,
+ &hudOption,
+ &priorityOption,
+ &rootOption,
+ &logfileOption
+ };
+
+const char *DefaultRootDir = "\\Flightgear";
+const char *DefaultAircraft = "Navion.acf";
+const char *DefaultDebuglog = "fgdebug.log";
+const int DefaultViewMode = HUD_VIEW;
+//
+// Debug defaults handled in fg_debug.c
+//
/**************************************************************************
* fgInitVisuals() -- Initialize various GL/view parameters
**************************************************************************/
static void fgInitVisuals( void ) {
struct fgLIGHT *l;
- struct fgTIME *t;
struct fgWEATHER *w;
l = &cur_light_params;
- t = &cur_time_params;
w = ¤t_weather;
-
/* xglDisable( GL_DITHER ); */
/* If enabled, normal vectors specified with glNormal are scaled
static void fgUpdateViewParams( void ) {
fgFLIGHT *f;
struct fgLIGHT *l;
- struct fgTIME *t;
+// struct fgTIME *t;
struct fgVIEW *v;
f = current_aircraft.flight;
l = &cur_light_params;
- t = &cur_time_params;
+// t = &cur_time_params;
v = ¤t_view;
fgViewUpdate(f, v, l);
if (displayInstruments)
{
xglViewport(0, (GLint)(winHeight / 2 ) , (GLint)winWidth, (GLint)winHeight / 2);
- /* Tell GL we are about to modify the projection parameters */
+ /* Tell GL we are about to modify the projection parameters */
xglMatrixMode(GL_PROJECTION);
xglLoadIdentity();
gluPerspective(55.0, 2.0/win_ratio, 1.0, 100000.0);
xglMatrixMode(GL_MODELVIEW);
xglPushMatrix();
xglLoadIdentity();
-
+
xglColor3f(1.0, 1.0, 1.0);
xglIndexi(7);
fgUpdateInstrViewParams();
}
- #ifdef GLUT
- xglutSwapBuffers();
- #endif
+ xglutSwapBuffers();
}
int main( int argc, char *argv[] ) {
fgFLIGHT *f;
+ int parse_result; // Used in command line argument.
f = current_aircraft.flight;
+ // First things first... We must have startup options dealt with.
+ #ifndef VERSION
+ #define VERSION "src-32A"
+ #endif
printf("Flight Gear: Version %s\n\n", VERSION);
- /**********************************************************************
+ /*********************************************************************
* Initialize the Window/Graphics environment.
**********************************************************************/
- #ifdef GLUT
- /* initialize GLUT */
- xglutInit(&argc, argv);
+ /* initialize GLUT */
+ xglutInit(&argc, argv);
- /* Define Display Parameters */
- xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
+ /* Define Display Parameters */
+ xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
- /* Define initial window size */
- xglutInitWindowSize(640, 480);
+ /* Define initial window size */
+ xglutInitWindowSize(640, 480);
- /* Initialize windows */
- xglutCreateWindow("Flight Gear");
- #endif
+ /* Initialize windows */
+ xglutCreateWindow("Flight Gear");
- /* This is the general house keeping init routine */
- fgInitGeneral();
+ // xglutInit above will extract all non-general program command line.
+ // We only need wory about our own.
- /* This is the top level init routine which calls all the other
- * subsystem initialization routines. If you are adding a
- * subsystem to flight gear, its initialization call should
- * located in this routine.*/
- fgInitSubsystems();
+ parse_result = getargs( argc, argv, OptsDefined, CmdLineOptions, NULL);
- /* setup view parameters, only makes GL calls */
- fgInitVisuals();
+ switch( parse_result ) {
+ case ALLDONE:
+ break;
- if ( use_signals ) {
- /* init timer routines, signals, etc. Arrange for an alarm
- signal to be generated, etc. */
- fgInitTimeDepCalcs();
+ case HELP:
+ print_desc( OptsDefined, CmdLineOptions );
+ exit(0);
+
+ case INVALID:
+ default:
+ printf( "Flight Gear: Command line invalid.");
+ exit(0);
}
- /**********************************************************************
- * Initialize the Event Handlers.
- **********************************************************************/
+ // Deal with the effects of options no set by manipulating the command
+ // line, or possibly set to invalid states.
+
+ if(( viewArg >= 0) && (viewArg < 1)) {
+ show_hud = viewArg; // For now view_mode TRUE - no HUD, else show_hud.
+ } else {
+ show_hud = DefaultViewMode;
+ }
- #ifdef GLUT
- /* call fgReshape() on window resizes */
- xglutReshapeFunc( fgReshape );
+ // All other command line option responses are handled in the various
+ // initialization routines (or ignored if not implemented.
- /* call key() on keyboard event */
- xglutKeyboardFunc( GLUTkey );
- glutSpecialFunc( GLUTspecialkey );
+ // This is the general house keeping init routine. It initializes the
+ // debug trail scheme and then any other stuff.
- /* call fgMainLoop() whenever there is nothing else to do */
- xglutIdleFunc( fgMainLoop );
+ if( !fgInitGeneral()) {
- /* draw the scene */
- xglutDisplayFunc( fgRenderFrame );
+ // This is the top level init routine which calls all the other
+ // subsystem initialization routines. If you are adding a
+ // subsystem to flight gear, its initialization call should
+ // located in this routine.
+ if( !fgInitSubsystems()) {
- /* pass control off to the GLUT event handler */
- glutMainLoop();
- #endif
+ // setup view parameters, only makes GL calls
+ fgInitVisuals();
+
+ if ( use_signals ) {
+ /* init timer routines, signals, etc. Arrange for an alarm
+ signal to be generated, etc. */
+ fgInitTimeDepCalcs();
+ }
+
+ /**********************************************************
+ * Initialize the GLUT Event Handlers.
+ **********************************************************/
+
+ // call fgReshape() on window resizes
+ xglutReshapeFunc( fgReshape );
+
+ // call key() on keyboard event
+ xglutKeyboardFunc( GLUTkey );
+ glutSpecialFunc( GLUTspecialkey );
+
+ // call fgMainLoop() whenever there is
+ // nothing else to do
+ xglutIdleFunc( fgMainLoop );
+ // draw the scene
+ xglutDisplayFunc( fgRenderFrame );
+
+ // pass control off to the GLUT event handler
+ glutMainLoop();
+
+ } // End if subsystems initialize ok
+ } // End if general initializations went ok
+
+ if( fg_DebugOutput ) {
+ fclose( fg_DebugOutput );
+ }
return(0);
}
#ifdef __SUNPRO_CC
- extern "C" {
- void __eprintf( void ) {
- }
+extern "C" {
+ void __eprintf( void ) {
}
+}
#endif
/* $Log$
-/* Revision 1.60 1998/02/11 02:50:40 curt
-/* Minor changes.
+/* Revision 1.61 1998/02/12 21:59:46 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.60 1998/02/11 02:50:40 curt
+ * Minor changes.
+ *
* Revision 1.59 1998/02/09 22:56:54 curt
* Removed "depend" files from cvs control. Other minor make tweaks.
*
TARGET = fg-$(FG_VERSION)
-CFILES = fg_init.c fg_debug.c views.c $(INTERFACE_FILES)
+CFILES = fg_debug.c fg_getopt.c fg_init.c views.c GLUTmain.c GLUTkey.c
FGLIBS = -lAircraft -lAstro -lCockpit -lControls -lFlight \
-lJoystick -lLaRCsim -lSlew -lScenery -lTime -lWeather -lMath \
LCDEFS = -DGLUT
LLDFLAGS =
-LDLIBS = $(FGLIBS) $(FG_DEBUG_LIBS) \
- $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm
+LDLIBS = $(FGLIBS) $(FG_DEBUG_LIBS) $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm
include $(FG_ROOT_SRC)/commondefs
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.48 1998/02/12 21:59:47 curt
+# Incorporated code changes contributed by Charlie Hotchkiss
+# <chotchkiss@namg.us.anritsu.com>
+#
# Revision 1.47 1998/02/09 22:56:56 curt
# Removed "depend" files from cvs control. Other minor make tweaks.
#
**************************************************************************/
#include <string.h>
-#include <Main/fg_debug.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
-static int fg_DebugSem = 1;
-static fgDebugClass fg_DebugClass = FG_ALL;
-static fgDebugPriority fg_DebugPriority = FG_INFO;
+#include <Include/cmdargs.h> // Line to command line arguments
+#include <Main/fg_debug.h>
+
+static int fg_DebugSem = 1;
+fgDebugClass fg_DebugClass = FG_ALL; // Need visibility for
+fgDebugPriority fg_DebugPriority = FG_INFO; // command line processing.
static fgDebugCallback fg_DebugCallback = NULL;
-#ifndef __CYGWIN32__
- static FILE *fg_DebugOutput = stderr;
-#else /* __CYGWIN32__ */
- static FILE *fg_DebugOutput = NULL;
-#endif /* __CYGWIN32 */
+FILE *fg_DebugOutput = NULL; // Visibility needed for command line processor.
+ // This can be set to a FILE from the command
+ // line. If not, it will be set to stderr.
/* TODO: Actually make this thing thread safe */
#ifdef USETHREADS
-#define FG_GRABDEBUGSEM while( --fg_DebugSem < 0 ) { fg_DebugSem++; }
+#define FG_GRABDEBUGSEM while( --fg_DebugSem < 0 ) { fg_DebugSem++; }
#define FG_RELEASEDEBUGSEM fg_DebugSem++;
#else
#define FG_GRABDEBUGSEM
-#define FG_RELEASEDEBUGSEM
+#define FG_RELEASEDEBUGSEM
#endif
/* Used for convienence initialization from env variables.
/* fgInitDebug =============================================================*/
void fgInitDebug( void )
{
- char *pszClass, *pszPrio;
+ char *pszClass, *pszPrio, *pszFile;
+
+ // Support for log file/alt debug output via command line, environment or
+ // reasonable default.
+
+ if( strlen( logArgbuf ) > 3) { // First check for command line option
+ fg_DebugOutput = fopen(logArgbuf, "a+" ); // Assumed that we will append.
+ }
+
+ if( !fg_DebugOutput ) { // If not set on command line, environment?
+ pszFile = getenv( "FG_DEBUGFILE" );
+ if( pszFile ) { // There is such an environmental variable.
+ fg_DebugOutput = fopen( pszFile, "a+" );
+ }
+ }
-#ifdef __CYGWIN32__
- fg_DebugOutput = stderr;
-#endif /* __CYGWIN32 */
+ if( !fg_DebugOutput ) { // If neither command line nor environment
+ fg_DebugOutput = stderr; // then we use the fallback position
+ }
FG_GRABDEBUGSEM;
- fg_DebugSem=fg_DebugSem; /* shut up GCC */
+ fg_DebugSem = fg_DebugSem; /* shut up GCC */
- pszPrio = getenv( "FG_DEBUGPRIORITY" );
- if( pszPrio ) {
- fg_DebugPriority = atoi( pszPrio );
- fprintf( stderr, "fg_debug.c: Environment overrides default debug priority (%d)\n",
- fg_DebugPriority );
- }
+ // Test command line option overridge of debug priority. If the value
+ // is in range (properly optioned) the we will override both defaults
+ // and the environmental value.
- pszClass = getenv( "FG_DEBUGCLASS" );
- if( pszClass ) {
- fg_DebugClass = fgDebugStrToClass( pszClass );
- fprintf( stderr, "fg_debug.c: Environment overrides default debug class (0x%08X)\n",
- fg_DebugClass );
- }
+ if ((priorityArgValue >= FG_BULK) && (priorityArgValue <= FG_ABORT)) {
+ fg_DebugPriority = priorityArgValue;
+ }
+ else { // Either not set or out of range. We will not warn the user.
+ pszPrio = getenv( "FG_DEBUGPRIORITY" );
+ if( pszPrio ) {
+ fg_DebugPriority = atoi( pszPrio );
+ fprintf( stderr,
+ "fg_debug.c: Environment overrides default debug priority (%d)\n",
+ fg_DebugPriority );
+ }
+ }
+
+
+ if ((debugArgValue >= FG_ALL) && (debugArgValue < FG_UNDEFD)) {
+ fg_DebugPriority = priorityArgValue;
+ }
+ else { // Either not set or out of range. We will not warn the user.
+ pszClass = getenv( "FG_DEBUGCLASS" );
+ if( pszClass ) {
+ fg_DebugClass = fgDebugStrToClass( pszClass );
+ fprintf( stderr,
+ "fg_debug.c: Environment overrides default debug class (0x%08X)\n",
+ fg_DebugClass );
+ }
+ }
FG_RELEASEDEBUGSEM;
}
{
char *hex = "0123456789ABCDEF";
char *hexl = "0123456789abcdef";
- char *pt, *p, *ph, ps=1;
+ char *pt, *p, *ph, ps = 1;
unsigned int val = 0, i;
if( str == NULL ) {
va_list ap;
int ret = 0;
- FG_GRABDEBUGSEM;
+ // If no action to take, then don't bother with the semaphore activity
+ // Slight speed benefit.
if( !(dbg_class & fg_DebugClass) || (prio < fg_DebugPriority) ) {
- FG_RELEASEDEBUGSEM;
- return 0;
- }
+ return ret; // Its zero anyway. But we might think about changing
+ // it upon some error condition?
+ }
+
+ FG_GRABDEBUGSEM;
/* ret = vsprintf( szOut, fmt, (&fmt+1)); (but it didn't work, thus ... */
va_start (ap, fmt);
if( fg_DebugCallback!=NULL && fg_DebugCallback(dbg_class, prio, szOut) ) {
FG_RELEASEDEBUGSEM;
return ret;
- }
+ }
else {
fprintf( fg_DebugOutput, szOut );
FG_RELEASEDEBUGSEM;
if( prio == FG_EXIT ) {
exit(0);
- }
+ }
else if( prio == FG_ABORT ) {
abort();
}
return ret;
}
+// Revision history?
+//
+
/* NB: To add a dbg_class, add it here, and add it to the structure
in fg_debug.c
*/
-typedef enum {
+typedef enum{
FG_NONE = 0x00000000,
FG_TERRAIN = 0x00000001,
FG_MATH = 0x00000100,
FG_EVENT = 0x00000200,
FG_AIRCRAFT= 0x00000400,
+ FG_UNDEFD = 0x00001000, // For range checking
- FG_ALL = 0xFFFFFFFF
-} fgDebugClass;
+ FG_ALL = 0xFFFFFFFFL // -1!
+ } fgDebugClass;
/* NB: To add a priority, add it here.
*/
-typedef enum {
- FG_BULK, /* For frequent messages */
- FG_DEBUG, /* Less frequent debug type messages */
- FG_INFO, /* Informatory messages */
- FG_WARN, /* Possible impending problem */
- FG_ALERT, /* Very possible impending problem */
- FG_EXIT, /* Problem (no core) */
- FG_ABORT /* Abandon ship (core) */
+typedef enum {
+ FG_BULK, /* For frequent messages */
+ FG_DEBUG, /* Less frequent debug type messages */
+ FG_INFO, /* Informatory messages */
+ FG_WARN, /* Possible impending problem */
+ FG_ALERT, /* Very possible impending problem */
+ FG_EXIT, /* Problem (no core) */
+ FG_ABORT /* Abandon ship (core) */
} fgDebugPriority;
/* Initialize the debuggin stuff. */
processing of the message.** Only one callback may be installed at a
time.
*/
-typedef int (*fgDebugCallback)(fgDebugClass, fgDebugPriority, char *outstr);
+
+//typedef int (*fgDebugCallback)(fgDebugClass, fgDebugPriority, char *outstr);
+//fgDebugCallback fgRegisterDebugCallback( fgDebugCallback callback );
+
+typedef int (*fgDebugCallback)( int DebugClass, int DebugPriority, char *outstr);
fgDebugCallback fgRegisterDebugCallback( fgDebugCallback callback );
+// Leave these alone. Access intended for fg_debug and command line processing.
+//
+extern fgDebugClass fg_DebugClass;
+extern fgDebugPriority fg_DebugPriority;
+
+extern FILE * fg_DebugOutput;
#endif /* _FG_DEBUG_H */
#include <Main/fg_init.h>
#include <Main/views.h>
+#include <Include/cmdargs.h>
#include <Include/fg_constants.h>
#include <Include/general.h>
extern int show_hud; /* HUD state */
extern int displayInstruments;
-
+extern const char *default_root;
/* General house keeping initializations */
-void fgInitGeneral( void ) {
+int fgInitGeneral( void ) {
struct fgGENERAL *g;
g = &general;
/* seed the random number generater */
fg_srandom();
- /* determine the fg root path */
- if ( (g->root_dir = getenv("FG_ROOT")) == NULL ) {
- /* environment variable not defined */
- fgPrintf(FG_GENERAL, FG_EXIT, "FG_ROOT needs to be defined! "
- "See the documentation.\n");
- }
+ // determine the fg root path. The command line parser getargs() will
+ // fill in a root directory if the option was used.
+
+ if( !(g->root_dir) ) {
+ // If not set by command line test for environmental var..
+ g->root_dir = getenv("FG_ROOT");
+ if ( !g->root_dir ) {
+ // No root path set? Then assume, we will exit if this is
+ // wrong when looking for support files.
+ g->root_dir = (char *)DefaultRootDir;
+ }
+ }
fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", g->root_dir);
+
+ // Dummy value can be changed if future initializations
+ // fail a critical task.
+ return ( 0 /* FALSE */ );
}
-/* This is the top level init routine which calls all the other
- * initialization routines. If you are adding a subsystem to flight
- * gear, its initialization call should located in this routine.*/
+// This is the top level init routine which calls all the other
+// initialization routines. If you are adding a subsystem to flight
+// gear, its initialization call should located in this routine.
+// Returns non-zero if a problem encountered.
-void fgInitSubsystems( void ) {
+int fgInitSubsystems( void ) {
double cur_elev;
+ // Ok will be flagged only if we get EVERYTHING done.
+ int ret_val = 1 /* TRUE */;
+
fgFLIGHT *f;
struct fgLIGHT *l;
struct fgTIME *t;
fgPrintf( FG_GENERAL, FG_INFO, "========== ==========\n");
/****************************************************************
- * The following section sets up the flight model EOM parameters and
+ * The following section sets up the flight model EOM parameters and
* should really be read in from one or more files.
****************************************************************/
/* Must happen before any of the flight model or control
* parameters are set */
- fgAircraftInit();
+
+ fgAircraftInit(); // In the future this might not be the case.
f = current_aircraft.flight;
/* Globe Aiport, AZ */
/* FG_Latitude = 45.145 * DEG_TO_RAD; */
/* FG_Runway_altitude = 912; */
/* FG_Altitude = FG_Runway_altitude + 3.758099; */
-
+
/* Initial Position north of the city of Globe */
/* FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD; */
/* FG_Latitude = ( 120625.64 / 3600.0 ) * DEG_TO_RAD; */
/* FG_Runway_altitude = 5000.0; */
/* FG_Altitude = FG_Runway_altitude + 3.758099; */
- /* Initial Position: (GCN) Grand Canyon Airport, AZ */
- FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD;
- FG_Latitude = ( 35.9523539 ) * DEG_TO_RAD;
- FG_Runway_altitude = 6606.0;
- FG_Altitude = FG_Runway_altitude + 3.758099;
+ // Initial Position: (GCN) Grand Canyon Airport, AZ
+ // FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD;
+ // FG_Latitude = ( 35.9523539 ) * DEG_TO_RAD;
+ // FG_Runway_altitude = 6606.0;
+ // FG_Altitude = FG_Runway_altitude + 3.758099;
+
+ // Initial Position: Jim Brennon's Kingmont Observatory
+ // FG_Longitude = ( -121.1131666 ) * DEG_TO_RAD;
+ // FG_Latitude = ( 38.8293916 ) * DEG_TO_RAD;
+ // FG_Runway_altitude = 920.0;
+ // FG_Altitude = FG_Runway_altitude + 3.758099;
/* A random test position */
/* FG_Longitude = ( 88128.00 / 3600.0 ) * DEG_TO_RAD; */
fgEventInit();
/* Dump event stats every 60 seconds */
- fgEventRegister( "fgEventPrintStats()", fgEventPrintStats,
+ fgEventRegister( "fgEventPrintStats()", fgEventPrintStats,
FG_EVENT_READY, 60000 );
/* Initialize "time" */
fgWeatherInit();
/* update the weather for our current position */
- fgEventRegister( "fgWeatherUpdate()", fgWeatherUpdate,
+ fgEventRegister( "fgWeatherUpdate()", fgWeatherUpdate,
FG_EVENT_READY, 120000 );
/* Initialize the Cockpit subsystem */
- if( fgCockpitInit( ¤t_aircraft ) == NULL ) {
+ if( fgCockpitInit( ¤t_aircraft )) {
+ // Cockpit initialized ok.
+ } else {
fgPrintf( FG_GENERAL, FG_EXIT, "Error in Cockpit initialization!\n" );
}
- /* Initialize the orbital elements of sun, moon and mayor planets */
+ // Initialize the orbital elements of sun, moon and mayor planets
fgSolarSystemInit(*t);
- /* Initialize the Stars subsystem */
- fgStarsInit();
+ // Initialize the Stars subsystem
+ if( fgStarsInit() ) {
+ // Stars initialized ok.
+ } else {
+ fgPrintf( FG_GENERAL, FG_EXIT, "Error in Stars initialization!\n" );
+ }
- /* Initialize the planetary subsystem */
+ // Initialize the planetary subsystem
fgEventRegister("fgPlanetsInit()", fgPlanetsInit, FG_EVENT_READY, 600000);
- /* Initialize the sun's position */
- fgEventRegister( "fgSunInit()", fgSunInit, FG_EVENT_READY, 60000 );
+ // Initialize the sun's position
+ fgEventRegister("fgSunInit()", fgSunInit, FG_EVENT_READY, 60000 );
- /* Intialize the moon's position */
+ // Intialize the moon's position
fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 );
- /* Initialize the "sky" */
+ // Initialize the "sky"
fgSkyInit();
- /* Initialize the Scenery Management subsystem */
- fgTileMgrInit();
- /* fgSceneryInit(); */
-
- /* Tell the Scenery Management system where we are so it can load
- * the correct scenery data */
- fgTileMgrUpdate();
- /* fgSceneryUpdate(FG_Latitude, FG_Longitude, FG_Altitude); */
-
- /* I'm just sticking this here for now, it should probably move
- * eventually */
- /* cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
- FG_Latitude * RAD_TO_DEG * 3600.0); */
- /* fgPrintf( FG_GENERAL, FG_INFO,
- "True ground elevation is %.2f meters here.\n",
- cur_elev); */
+ // Initialize the Scenery Management subsystem
+ if( fgTileMgrInit() ) {
+ // Load the local scenery data
+ fgTileMgrUpdate();
+ } else {
+ fgPrintf( FG_GENERAL, FG_EXIT,
+ "Error in Tile Manager initialization!\n" );
+ }
+
+ // I'm just sticking this here for now, it should probably move
+ // eventually
+ // cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
+ // FG_Latitude * RAD_TO_DEG * 3600.0); */
+ // fgPrintf( FG_GENERAL, FG_INFO,
+ // "True ground elevation is %.2f meters here.\n",
+ // cur_elev); */
+
cur_elev = FG_Runway_altitude * FEET_TO_METER;
if ( cur_elev > -9990.0 ) {
FG_Runway_altitude = cur_elev * METER_TO_FEET;
if ( FG_Altitude < FG_Runway_altitude ) {
FG_Altitude = FG_Runway_altitude + 3.758099;
}
+
fgPrintf(FG_GENERAL, FG_INFO,
- "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
- FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
- FG_Altitude * FEET_TO_METER);
- /* end of thing that I just stuck in that I should probably move */
+ "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
+ FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
+ FG_Altitude * FEET_TO_METER);
+ /* end of thing that I just stuck in that I should probably move */
+
/* Initialize the flight model subsystem data structures base on
* above values */
+
fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
- /* To HUD or not to HUD */
- show_hud = 0;
+ // To HUD or not to HUD - Now a command line issue
+ // show_hud = 0;
- /* Let's show the instrument panel */
+ // Let's not show the instrument panel
displayInstruments = 0;
- /* Joystick support */
- fgJoystickInit( 0 );
+ // Joystick support
+ if (fgJoystickInit(0) ) {
+ // Joystick initialized ok.
+ } else {
+ fgPrintf( FG_GENERAL, FG_EXIT, "Error in Joystick initialization!\n" );
+ }
- /* One more try here to get the sky synced up */
+ // One more try here to get the sky synced up
fgSkyColorsInit();
+ ret_val = 0;
fgPrintf(FG_GENERAL, FG_INFO,"\n");
+ return ret_val;
}
/* $Log$
-/* Revision 1.43 1998/02/11 02:50:40 curt
-/* Minor changes.
+/* Revision 1.44 1998/02/12 21:59:50 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.43 1998/02/11 02:50:40 curt
+ * Minor changes.
+ *
* Revision 1.42 1998/02/09 22:56:58 curt
* Removed "depend" files from cvs control. Other minor make tweaks.
*
#define _FG_INIT_H
-/* General house keeping initializations */
-void fgInitGeneral( void );
+// General house keeping initializations
+int fgInitGeneral ( void );
-/* This is the top level init routine which calls all the other
- * initialization routines. If you are adding a subsystem to flight
- * gear, its initialization call should located in this routine.*/
-void fgInitSubsystems( void );
+// This is the top level init routine which calls all the other
+// initialization routines. If you are adding a subsystem to flight
+// gear, its initialization call should located in this routine.
+int fgInitSubsystems( void );
#endif /* _FG_INIT_H */
/* $Log$
-/* Revision 1.2 1998/01/22 02:59:38 curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.3 1998/02/12 21:59:50 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.2 1998/01/22 02:59:38 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
* Revision 1.1 1997/08/23 01:46:20 curt
* Initial revision.
*
static ImageRec *ImageOpen(char *fileName)
{
- union {
- int testWord;
- char testByte[4];
- } endianTest;
+ union {
+ int testWord;
+ char testByte[4];
+ } endianTest;
+
ImageRec *image;
int swapFlag;
int x;
exit(1);
}
if ((image->file = fopen(fileName, "rb")) == NULL) {
- return NULL;
+ return NULL;
}
fread(image, 1, 12, image->file);
/* Initialize the Tile Manager subsystem */
-void fgTileMgrInit( void ) {
+int fgTileMgrInit( void ) {
fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
+ return 1;
}
/* given the current lon/lat, fill in the array of local chunks. If
* the chunk isn't already in the cache, then read it from disk. */
-void fgTileMgrUpdate( void ) {
+int fgTileMgrUpdate( void ) {
fgFLIGHT *f;
struct fgBUCKET p1, p2;
static struct fgBUCKET p_last = {-1000, 0, 0, 0};
dw = FG_LOCAL_X / 2;
dh = FG_LOCAL_Y / 2;
- if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
+ if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
(p1.x == p_last.x) && (p1.y == p_last.y) ) {
/* same bucket as last time */
fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n");
* relavant tiles */
fgPrintf( FG_TERRAIN, FG_DEBUG, "First time through ... \n");
- fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n",
- p1.lon, p1.lat, p1.x, p1.y);
+ fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n",
+ p1.lon, p1.lat, p1.x, p1.y);
/* wipe tile cache */
fgTileCacheInit();
AT ULTRA HIGH SPEEDS THIS ASSUMPTION MAY NOT BE VALID IF
THE AIRCRAFT CAN SKIP A TILE IN A SINGLE ITERATION. */
- if ( (p1.lon > p_last.lon) ||
+ if ( (p1.lon > p_last.lon) ||
( (p1.lon == p_last.lon) && (p1.x > p_last.x) ) ) {
for ( j = 0; j < FG_LOCAL_Y; j++ ) {
/* scrolling East */
fgBucketOffset(&p_last, &p2, dw + 1, j - dh);
fgTileMgrLoadTile(&p2, &tiles[(j*FG_LOCAL_Y) + FG_LOCAL_X - 1]);
}
- } else if ( (p1.lon < p_last.lon) ||
+ } else if ( (p1.lon < p_last.lon) ||
( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) {
for ( j = 0; j < FG_LOCAL_Y; j++ ) {
/* scrolling West */
}
}
- if ( (p1.lat > p_last.lat) ||
+ if ( (p1.lat > p_last.lat) ||
( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) {
for ( i = 0; i < FG_LOCAL_X; i++ ) {
/* scrolling North */
for ( j = 0; j < FG_LOCAL_Y - 1; j++ ) {
- tiles[(j * FG_LOCAL_Y) + i] =
+ tiles[(j * FG_LOCAL_Y) + i] =
tiles[((j+1) * FG_LOCAL_Y) + i];
}
/* load in new column */
fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
- fgTileMgrLoadTile(&p2,
- &tiles[((FG_LOCAL_Y-1)*FG_LOCAL_Y) + i]);
+ fgTileMgrLoadTile(&p2, &tiles[((FG_LOCAL_Y-1)*FG_LOCAL_Y) + i]);
}
- } else if ( (p1.lat < p_last.lat) ||
+ } else if ( (p1.lat < p_last.lat) ||
( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
for ( i = 0; i < FG_LOCAL_X; i++ ) {
/* scrolling South */
fgBucketOffset(&p_last, &p2, i - dw, -dh - 1);
fgTileMgrLoadTile(&p2, &tiles[0 + i]);
}
- }
+ }
}
p_last.lon = p1.lon;
p_last.lat = p1.lat;
p_last.x = p1.x;
p_last.y = p1.y;
+ return 1;
}
/* $Log$
-/* Revision 1.15 1998/02/11 02:50:44 curt
-/* Minor changes.
+/* Revision 1.16 1998/02/12 21:59:53 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
* Revision 1.14 1998/02/09 21:30:19 curt
* Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.
/* Initialize the Tile Manager subsystem */
-void fgTileMgrInit( void );
+int fgTileMgrInit( void );
/* given the current lon/lat, fill in the array of local chunks. If
* the chunk isn't already in the cache, then read it from disk. */
-void fgTileMgrUpdate( void );
+int fgTileMgrUpdate( void );
/* Render the local tiles --- hack, hack, hack */
/* $Log$
-/* Revision 1.4 1998/01/22 02:59:42 curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.5 1998/02/12 21:59:53 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.4 1998/01/22 02:59:42 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
* Revision 1.3 1998/01/19 18:40:38 curt
* Tons of little changes to clean up the code and to remove fatal errors
* when building with the c++ compiler.
| Todo
--------------------------------------------------------------------------
+1/12/98 - Fix time problem on win32
+
12/29/97 - View frustum culling
1/5/98 - Create a development "roadmap"
#
#---------------------------------------------------------------------------
-GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\"
+GLOBAL_CFLAGS = -Wall -DVERSION=\"$(FG_VERSION)\"
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Linux/Mesa with the GLUT toolkit
#
-INTERFACE_FLAGS = -DGLUT
INTERFACE_LIBS = -lglut
-INTERFACE_FILES = GLUTmain.c GLUTkey.c
MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL
X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11
GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
# (Surprisingly, this also works on our SunOS 4.x machine with the
# way we have Mesa & Glut installed.)
#
-# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = -lglut
-# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11
# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS)
# EXT =
# Sun/Solaris with the GLUT toolkit
#
# VERSION=\"$(VERSION)\"
-# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = -lglut
-# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -L/opt/X11R6/lib -lGLU -lGL -lXext -lXmu -lXi -lX11 -lsocket
# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS)
# EXT =
#---------------------------------------------------------------------------
# Cygnus Win32 (gcc based) with a static version of the GLUT toolkit
#
-# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = ../Win32/libglut.a
-# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -lglu32 -lopengl32 -luser32 -lgdi32
# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) -DWIN32 -DUSE_RAND
# EXT = .exe