1
0
Fork 0

Incorporated code changes contributed by Charlie Hotchkiss

<chotchkiss@namg.us.anritsu.com>
This commit is contained in:
curt 1998-02-12 21:58:27 +00:00
parent 9c90c31a49
commit 913fe75558
23 changed files with 750 additions and 404 deletions

View file

@ -39,7 +39,7 @@ fgAIRCRAFT current_aircraft;
void fgAircraftInit( void ) { void fgAircraftInit( void ) {
fgPrintf( FG_AIRCRAFT, FG_INFO, "Initializing Aircraft structure\n" ); 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; current_aircraft.controls = &cur_control_params;
} }
@ -64,10 +64,14 @@ void fgAircraftOutputCurrent(fgAIRCRAFT *a) {
/* $Log$ /* $Log$
/* Revision 1.16 1998/02/07 15:29:31 curt /* Revision 1.17 1998/02/12 21:59:31 curt
/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss /* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com> /* <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 * Revision 1.15 1998/01/27 00:47:46 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code. * system and commandline/config file processing code.

View file

@ -101,6 +101,8 @@ double fgCalcEccAnom(double M, double e)
} }
// 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) void fgReadOrbElements(struct OrbElements *dest, FILE *src)
{ {
@ -119,49 +121,51 @@ void fgReadOrbElements(struct OrbElements *dest, FILE *src)
} }
while (!(strlen(line))); while (!(strlen(line)));
sscanf(line, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n", sscanf(line, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n",
&dest->NFirst, &dest->NSec, &dest->NFirst, &dest->NSec,
&dest->iFirst, &dest->iSec, &dest->iFirst, &dest->iSec,
&dest->wFirst, &dest->wSec, &dest->wFirst, &dest->wSec,
&dest->aFirst, &dest->aSec, &dest->aFirst, &dest->aSec,
&dest->eFirst, &dest->eSec, &dest->eFirst, &dest->eSec,
&dest->MFirst, &dest->MSec); &dest->MFirst, &dest->MSec);
} }
void fgSolarSystemInit(struct fgTIME t) int fgSolarSystemInit(struct fgTIME t)
{ {
struct fgGENERAL *g; struct fgGENERAL *g;
char path[80]; char path[80];
int i; int i;
FILE *data; 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 */ /* build the full path name to the orbital elements database file */
g = &general; g = &general;
path[0] = '\0'; path[0] = '\0';
strcat(path, g->root_dir); strcat(path, g->root_dir);
strcat(path, "/Scenery/"); strcat(path, "/Scenery/");
strcat(path, "Planets.dat"); strcat(path, "Planets.dat");
if ( (data = fopen(path, "r")) == NULL ) if ( (data = fopen(path, "r")) == NULL )
{ {
fgPrintf( FG_ASTRO, FG_ALERT, fgPrintf( FG_ASTRO, FG_ALERT,
"Cannot open data file: '%s'\n", path); "Cannot open data file: '%s'\n", path);
return; } else {
} /* printf(" reading datafile %s\n", path); */
/* printf(" reading datafile %s\n", path); */ fgPrintf( FG_ASTRO, FG_INFO, " 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);
}
/* 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;
} }
@ -183,12 +187,16 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
/* $Log$ /* $Log$
/* Revision 1.6 1998/02/03 23:20:11 curt /* Revision 1.7 1998/02/12 21:59:33 curt
/* Lots of little tweaks to fix various consistency problems discovered by /* Incorporated code changes contributed by Charlie Hotchkiss
/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper /* <chotchkiss@namg.us.anritsu.com>
/* passed arguments along to the real printf(). Also incorporated HUD changes
/* by Michele America.
/* /*
* 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 * Revision 1.5 1998/02/02 20:53:22 curt
* To version 0.29 * To version 0.29
* *

View file

@ -73,7 +73,7 @@ double fgCalcEccAnom(double M, double e);
double fgCalcActTime(struct fgTIME t); double fgCalcActTime(struct fgTIME t);
void fgReadOrbElements(struct OrbElements *dest, FILE *src); 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); void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
@ -81,9 +81,13 @@ void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
/* $Log$ /* $Log$
/* Revision 1.4 1998/02/02 20:53:22 curt /* Revision 1.5 1998/02/12 21:59:35 curt
/* To version 0.29 /* 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 * Revision 1.3 1998/01/22 02:59:27 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H * Changed #ifdef FILE_H to #ifdef _FILE_H
* *

View file

@ -204,12 +204,16 @@ void fgPlanetsRender( void ) {
/* $Log$ /* $Log$
/* Revision 1.5 1998/02/03 23:20:12 curt /* Revision 1.6 1998/02/12 21:59:36 curt
/* Lots of little tweaks to fix various consistency problems discovered by /* Incorporated code changes contributed by Charlie Hotchkiss
/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper /* <chotchkiss@namg.us.anritsu.com>
/* passed arguments along to the real printf(). Also incorporated HUD changes
/* by Michele America.
/* /*
* 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 * Revision 1.4 1998/02/02 20:53:23 curt
* To version 0.29 * To version 0.29
* *

View file

@ -32,17 +32,21 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
struct fgTIME t, int idx); struct fgTIME t, int idx);
void fgPlanetsInit(); void fgPlanetsInit( void );
void fgPlanetsRender(); void fgPlanetsRender( void );
#endif /* PLANETS_H */ #endif /* PLANETS_H */
/* $Log$ /* $Log$
/* Revision 1.3 1998/02/02 20:53:23 curt /* Revision 1.4 1998/02/12 21:59:38 curt
/* To version 0.29 /* 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 * Revision 1.2 1998/01/22 02:59:28 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H * Changed #ifdef FILE_H to #ifdef _FILE_H
* *

View file

@ -56,7 +56,7 @@
/* Initialize the Star Management Subsystem */ /* Initialize the Star Management Subsystem */
void fgStarsInit( void ) { int fgStarsInit( void ) {
FILE *fd; FILE *fd;
struct fgGENERAL *g; struct fgGENERAL *g;
/* struct CelestialCoord pltPos; */ /* struct CelestialCoord pltPos; */
@ -87,7 +87,7 @@ void fgStarsInit( void ) {
if ( (fd = fopen(path, "r")) == NULL ) { if ( (fd = fopen(path, "r")) == NULL ) {
fgPrintf( FG_ASTRO, FG_ALERT, fgPrintf( FG_ASTRO, FG_ALERT,
"Cannot open star file: '%s'\n", path); "Cannot open star file: '%s'\n", path);
return; return 0; // Oops, lets not even try to continue. This is critical.
} }
stars[i] = xglGenLists(1); stars[i] = xglGenLists(1);
@ -129,20 +129,20 @@ void fgStarsInit( void ) {
&right_ascension, &declination, &magnitude); &right_ascension, &declination, &magnitude);
/* /*
if ( strcmp(name, "Betelgeuse") == 0 ) { if ( strcmp(name, "Betelgeuse") == 0 ) {
printf(" *** Marking %s\n", name); printf(" *** Marking %s\n", name);
ra_save = right_ascension; ra_save = right_ascension;
decl_save = declination; decl_save = declination;
} }
*/ */
/* /*
if ( strcmp(name, "Alnilam") == 0 ) { if ( strcmp(name, "Alnilam") == 0 ) {
printf(" *** Marking %s\n", name); printf(" *** Marking %s\n", name);
ra_save1 = right_ascension; ra_save1 = right_ascension;
decl_save1 = declination; decl_save1 = declination;
} }
*/ */
/* scale magnitudes to (0.0 - 1.0) */ /* scale magnitudes to (0.0 - 1.0) */
magnitude = (0.0 - magnitude) / 5.0 + 1.0; magnitude = (0.0 - magnitude) / 5.0 + 1.0;
@ -153,7 +153,7 @@ void fgStarsInit( void ) {
magnitude = magnitude =
magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1); magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1);
/* printf(" Found star: %d %s, %.3f %.3f %.3f\n", count, /* 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( magnitude, magnitude, magnitude );
/*xglColor3f(0,0,0);*/ /*xglColor3f(0,0,0);*/
@ -162,7 +162,7 @@ void fgStarsInit( void ) {
50000.0 * sin(declination) ); 50000.0 * sin(declination) );
count++; count++;
} /* if valid line */ } // valid line
} /* while */ } /* while */
@ -210,6 +210,8 @@ void fgStarsInit( void ) {
max_stars /= 2; max_stars /= 2;
} }
return 1; // OK, we got here because initialization worked.
} }
@ -253,9 +255,13 @@ void fgStarsRender( void ) {
/* $Log$ /* $Log$
/* Revision 1.7 1998/02/09 15:07:48 curt /* Revision 1.8 1998/02/12 21:59:38 curt
/* Minor tweaks. /* 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 * Revision 1.6 1998/02/02 20:53:23 curt
* To version 0.29 * To version 0.29
* *

View file

@ -33,7 +33,7 @@
#define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */ #define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */
/* Initialize the Star Management Subsystem */ /* Initialize the Star Management Subsystem */
void fgStarsInit( void ); int fgStarsInit( void );
/* Draw the Stars */ /* Draw the Stars */
void fgStarsRender( void ); void fgStarsRender( void );
@ -44,9 +44,13 @@ extern struct fgTIME cur_time_params;
/* $Log$ /* $Log$
/* Revision 1.3 1998/01/22 02:59:28 curt /* Revision 1.4 1998/02/12 21:59:39 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H /* 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 * Revision 1.2 1998/01/19 18:40:18 curt
* Tons of little changes to clean up the code and to remove fatal errors * Tons of little changes to clean up the code and to remove fatal errors
* when building with the c++ compiler. * when building with the c++ compiler.

View file

@ -114,6 +114,7 @@ void fgSunInit( void ) {
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params); fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params); sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
fgPrintf( FG_ASTRO, FG_INFO, fgPrintf( FG_ASTRO, FG_INFO,
"Sun found at %f (ra), %f (dec)\n", "Sun found at %f (ra), %f (dec)\n",
sunPos.RightAscension, sunPos.Declination); sunPos.RightAscension, sunPos.Declination);
@ -156,10 +157,10 @@ void fgSunInit( void ) {
if (amb[2] > 1.0) amb[2] = 1.0; if (amb[2] > 1.0) amb[2] = 1.0;
fgPrintf( FG_ASTRO, FG_DEBUG, fgPrintf( FG_ASTRO, FG_DEBUG,
"Color of the sun: %f, %f, %f\n" "Color of the sun: %f, %f, %f\n"
"Ambient value : %f\n" "Ambient value : %f\n"
"Sun Angle : %f\n" , "Sun Angle : %f\n" ,
amb[0], amb[1], amb[2], ambient, l->sun_angle); amb[0], amb[1], amb[2], ambient, l->sun_angle);
/* set lighting parameters */ /* set lighting parameters */
/*xglLightfv(GL_LIGHT0, GL_AMBIENT, color ); /*xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
@ -195,9 +196,13 @@ void fgSunRender( void ) {
/* $Log$ /* $Log$
/* Revision 1.5 1998/02/02 20:53:24 curt /* Revision 1.6 1998/02/12 21:59:39 curt
/* To version 0.29 /* 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 * Revision 1.4 1998/01/27 00:47:50 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code. * system and commandline/config file processing code.

View file

@ -33,8 +33,8 @@
#include <string.h> #include <string.h>
#ifndef WIN32 #ifndef WIN32
# include <values.h> /* for MAXINT */ # include <values.h> // for MAXINT
#endif /* not WIN32 */ #endif //
#include "hud.h" #include "hud.h"
@ -45,7 +45,6 @@
#include <Math/mat3.h> #include <Math/mat3.h>
#include <Math/polar.h> #include <Math/polar.h>
#include <Scenery/scenery.h> #include <Scenery/scenery.h>
// #include <Scenery/mesh.h> /* not used any more :-) */
#include <Time/fg_timer.h> #include <Time/fg_timer.h>
#include <Weather/weather.h> #include <Weather/weather.h>
@ -216,53 +215,61 @@ static void drawscale( HUD_scale * pscale )
factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units; 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 ) if( pscale->sub_type == LIMIT ) {
condition = i>= pscale->minimum_value; condition = (i >= pscale->minimum_value);
else }
if( pscale->sub_type == NOLIMIT ) else {
if( pscale->sub_type == NOLIMIT ) {
condition = 1; condition = 1;
}
}
if( condition ) if( condition )
{ {
marker_y = pscale->scr_min+(i-vmin)*factor; marker_y = pscale->scr_min + (i - vmin) * factor;
if( i%pscale->div_min==0 ) if( !(i%pscale->div_min)) {
if( pscale->orientation == LEFT ) 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 ) 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 ) 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 ); sprintf( TextScale, "%d", i );
if( pscale->orientation == LEFT ) 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 ); TextScale, GLUT_BITMAP_8_BY_13 );
} }
else else {
if( pscale->orientation == RIGHT ) if( pscale->orientation == RIGHT )
{ {
textString( marker_x+10, marker_y-4, textString( marker_x+10, marker_y-4,
TextScale, GLUT_BITMAP_8_BY_13 ); TextScale, GLUT_BITMAP_8_BY_13 );
} }
}
} }
} }
}
}
} // End for range of i from vmin to vmax } // End for range of i from vmin to vmax
} }
if( pscale->type == HORIZONTAL ) // Horizontal scale if( pscale->type == HORIZONTAL ) // Horizontal scale
{ {
if( pscale->orientation == TOP ) if( pscale->orientation == TOP ) {
marker_y = pscale->scr_pos; marker_y = pscale->scr_pos;
else }
if( pscale->orientation == BOTTOM ) else {
marker_y = pscale->scr_pos-6; if( pscale->orientation == BOTTOM ) {
marker_y = pscale->scr_pos - 6;
}
}
drawOneLine( pscale->scr_min, drawOneLine( pscale->scr_min,
pscale->scr_pos, pscale->scr_pos,
pscale->scr_max, pscale->scr_max,
@ -285,7 +292,7 @@ static void drawscale( HUD_scale * pscale )
pscale->scr_pos-6 ); pscale->scr_pos-6 );
} }
else else {
if( pscale->orientation == BOTTOM ) if( pscale->orientation == BOTTOM )
{ {
drawOneLine( pscale->scr_min, drawOneLine( pscale->scr_min,
@ -303,58 +310,61 @@ static void drawscale( HUD_scale * pscale )
mid_scr, mid_scr,
pscale->scr_pos+6 ); pscale->scr_pos+6 );
} }
}
factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units; 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 ) if( pscale->sub_type == LIMIT ) {
condition = i>= pscale->minimum_value; condition = (i >= pscale->minimum_value);
else }
if( pscale->sub_type == NOLIMIT ) else {
if( pscale->sub_type == NOLIMIT ) {
condition = 1; condition = 1;
}
}
if( condition ) if( condition )
{ {
marker_x = pscale->scr_min+(i-vmin)*factor; marker_x = pscale->scr_min+(i-vmin)*factor;
if( i%pscale->div_min==0 ) if( i%pscale->div_min==0 ) {
if( pscale->orientation == TOP ) if( pscale->orientation == TOP )
{ {
drawOneLine( marker_x, marker_y, marker_x, marker_y+3 ); drawOneLine( marker_x, marker_y, marker_x, marker_y+3 );
} }
else else {
if( pscale->orientation == BOTTOM ) if( pscale->orientation == BOTTOM )
{ {
drawOneLine( marker_x, marker_y+3, marker_x, marker_y+6 ); 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 ); drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
if( pscale->orientation == TOP ) 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 ); 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 ); 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 ) static void drawladder( HUD_ladder *ladder )
{ {
@ -402,10 +412,12 @@ static void drawladder( HUD_ladder *ladder )
sprintf( TextLadder, "%d", i ); sprintf( TextLadder, "%d", i );
if( ladder->scr_hole == 0 ) if( ladder->scr_hole == 0 )
{ {
if( i ) if( i ) {
x_ini = ladder->x_pos - ladder->scr_width/2; x_ini = ladder->x_pos - ladder->scr_width/2;
else }
else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10; x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
}
y_ini = marker_y; y_ini = marker_y;
x_end = ladder->x_pos + ladder->scr_width/2; x_end = ladder->x_pos + ladder->scr_width/2;
y_end = marker_y; y_end = marker_y;
@ -442,10 +454,12 @@ static void drawladder( HUD_ladder *ladder )
} }
else else
{ {
if( i != 0 ) if( i != 0 ) {
x_ini = ladder->x_pos - ladder->scr_width/2; x_ini = ladder->x_pos - ladder->scr_width/2;
else }
else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10; x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
}
y_ini = marker_y; y_ini = marker_y;
x_end = ladder->x_pos - ladder->scr_width/2 + ladder->scr_hole/2; x_end = ladder->x_pos - ladder->scr_width/2 + ladder->scr_hole/2;
y_end = marker_y; y_end = marker_y;
@ -479,10 +493,12 @@ static void drawladder( HUD_ladder *ladder )
x_ini = ladder->x_pos + ladder->scr_width/2 - ladder->scr_hole/2; x_ini = ladder->x_pos + ladder->scr_width/2 - ladder->scr_hole/2;
y_ini = marker_y; y_ini = marker_y;
if( i != 0 ) if( i != 0 ) {
x_end = ladder->x_pos + ladder->scr_width/2; x_end = ladder->x_pos + ladder->scr_width/2;
else }
else {
x_end = ladder->x_pos + ladder->scr_width/2 + 10; x_end = ladder->x_pos + ladder->scr_width/2 + 10;
}
y_end = marker_y; y_end = marker_y;
new_x_ini = ladder->x_pos + \ new_x_ini = ladder->x_pos + \
(x_ini-ladder->x_pos)*cos(roll_value) -\ (x_ini-ladder->x_pos)*cos(roll_value) -\
@ -571,14 +587,12 @@ static void drawhorizon( HUD_horizon *horizon )
horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 ); horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 );
} }
} }
/*
Draws a representation of the control surfaces in their current state // drawControlSurfaces()
anywhere in the HUD // Draws a representation of the control surfaces in their current state
// anywhere in the HUD
//
Needs: struct HUD_control_surfaces
*/
static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf ) static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf )
{ {
int x_ini, y_ini; int x_ini, y_ini;
@ -711,12 +725,12 @@ static void drawlabel( HUD_label *label )
sprintf( string, buffer, (*label->load_value)() ); sprintf( string, buffer, (*label->load_value)() );
#ifdef DEBUGHUD
fgPrintf( FG_COCKPIT, FG_DEBUG, buffer ); fgPrintf( FG_COCKPIT, FG_DEBUG, buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" ); fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, string ); fgPrintf( FG_COCKPIT, FG_DEBUG, string );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" ); fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
#endif
lenstr = strlen( string ); lenstr = strlen( string );
if( label->justify == LEFT_JUST ) { if( label->justify == LEFT_JUST ) {
posincr = -lenstr*8; posincr = -lenstr*8;
@ -767,7 +781,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
hud->code = 1; hud->code = 1;
hud->status = 0; 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 // In the future, hud information has to come from the same place
// aircraft information came from. // aircraft information came from.
@ -784,7 +798,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
RIGHT_JUST, NULL, " m", "%5.0f", get_altitude ); RIGHT_JUST, NULL, " m", "%5.0f", get_altitude );
fgHUDAddLadder ( hud, 330, 190, 90, 180, 70, 10, fgHUDAddLadder ( hud, 330, 190, 90, 180, 70, 10,
NONE, 45, get_roll, get_pitch ); NONE, 45, get_roll, get_pitch );
// fgHUDAddControlSurfaces( hud, 10, 10, get_heading ); fgHUDAddControlSurfaces( hud, 10, 10, get_heading );
return( hud ); return( hud );
} }
@ -1011,6 +1025,50 @@ Hptr fgHUDAddLadder( Hptr hud, \
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, \ Hptr fgHUDAddMovingHorizon( Hptr hud, \
int x_pos, \ int x_pos, \
@ -1073,9 +1131,8 @@ void fgUpdateHUD( Hptr hud ) {
glLineWidth(1); glLineWidth(1);
glColor3f (0.1, 0.9, 0.1); glColor3f (0.1, 0.9, 0.1);
fgPrintf( FG_COCKPIT, FG_DEBUG, fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
"HUD Code %d Status %d\n", hud->code, hud->status );
hud->code, hud->status );
phud_instr = hud->instruments; phud_instr = hud->instruments;
while( phud_instr ) { while( phud_instr ) {
@ -1100,6 +1157,7 @@ void fgUpdateHUD( Hptr hud ) {
case HUDcontrols: case HUDcontrols:
drawControlSurfaces( (pHUDControlSurface) phud_instr->instr ); drawControlSurfaces( (pHUDControlSurface) phud_instr->instr );
break;
default:; // Ignore anything you don't know about. default:; // Ignore anything you don't know about.
} }
@ -1117,8 +1175,9 @@ void fgUpdateHUD( Hptr hud ) {
/* $Log$ /* $Log$
/* Revision 1.13 1998/02/11 02:50:19 curt /* Revision 1.14 1998/02/12 21:59:41 curt
/* Added changes submitted by Michele America. /* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/* /*
* Revision 1.12 1998/02/09 15:07:48 curt * Revision 1.12 1998/02/09 15:07:48 curt
* Minor tweaks. * Minor tweaks.

View file

@ -32,14 +32,17 @@
#include <Flight/flight.h> #include <Flight/flight.h>
#include <Controls/controls.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 ARTIFICIAL_HORIZON 1
#define SCALE 2 #define SCALE 2
#define LADDER 3 #define LADDER 3
#define LABEL 4 #define LABEL 4
/* Scale constants */ // Scale constants
#define HORIZONTAL 1 #define HORIZONTAL 1
#define TOP 2 #define TOP 2
#define BOTTOM 3 #define BOTTOM 3
@ -50,7 +53,7 @@
#define NOLIMIT 8 #define NOLIMIT 8
#define ROUNDROB 9 #define ROUNDROB 9
/* Label constants */ // Label constants
#define SMALL 1 #define SMALL 1
#define LARGE 2 #define LARGE 2
#define BLINK 3 #define BLINK 3
@ -59,7 +62,7 @@
#define CENTER_JUST 6 #define CENTER_JUST 6
#define RIGHT_JUST 7 #define RIGHT_JUST 7
/* Ladder constants */ // Ladder constants
#define NONE 1 #define NONE 1
#define UPPER_LEFT 2 #define UPPER_LEFT 2
#define UPPER_CENTER 3 #define UPPER_CENTER 3
@ -73,12 +76,12 @@
#define DASHED_LINES 11 #define DASHED_LINES 11
#define DASHED_NEG_LINES 12 #define DASHED_NEG_LINES 12
/* Ladder orientaion */ // Ladder orientaion
// #define HUD_VERTICAL 1 // #define HUD_VERTICAL 1
// #define HUD_HORIZONTAL 2 // #define HUD_HORIZONTAL 2
// #define HUD_FREEFLOAT 3 // #define HUD_FREEFLOAT 3
/* Ladder orientation modes */ // Ladder orientation modes
// #define HUD_LEFT 1 // #define HUD_LEFT 1
// #define HUD_RIGHT 2 // #define HUD_RIGHT 2
// #define HUD_TOP 1 // #define HUD_TOP 1
@ -89,7 +92,7 @@
// #define HUD_H_BOTTOM 2 // #define HUD_H_BOTTOM 2
/* Ladder sub-types */ // Ladder sub-types
// #define HUD_LIM 1 // #define HUD_LIM 1
// #define HUD_NOLIM 2 // #define HUD_NOLIM 2
// #define HUD_CIRC 3 // #define HUD_CIRC 3
@ -203,7 +206,7 @@ typedef struct {
// Removed union HUD_instr_data to evolve this to oop code. // Removed union HUD_instr_data to evolve this to oop code.
enum hudinstypes { HUDno_instr, typedef enum{ HUDno_instr,
HUDscale, HUDscale,
HUDcirc_scale, HUDcirc_scale,
HUDladder, HUDladder,
@ -211,10 +214,10 @@ enum hudinstypes { HUDno_instr,
HUDhorizon, HUDhorizon,
HUDlabel, HUDlabel,
HUDcontrols HUDcontrols
}; } hudinstype;
typedef struct HUD_INSTR_STRUCT{ typedef struct HUD_INSTR_STRUCT{
int type; hudinstype type;
int sub_type; int sub_type;
int orientation; int orientation;
void *instr; // For now we will cast this pointer accoring to the value void *instr; // For now we will cast this pointer accoring to the value
@ -312,12 +315,12 @@ void fgUpdateHUD ( Hptr hud );
void fgUpdateHUD2( Hptr hud ); // Future use? void fgUpdateHUD2( Hptr hud ); // Future use?
#endif /* _HUD_H */ #endif // _HUD_H
/* $Log$ /* $Log$
/* Revision 1.9 1998/02/11 02:50:22 curt /* Revision 1.10 1998/02/12 21:59:42 curt
/* Added changes submitted by Michele America. /* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/* /*
* Revision 1.8 1998/02/07 15:29:35 curt * Revision 1.8 1998/02/07 15:29:35 curt
* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss

View file

@ -208,7 +208,7 @@ int fgJoystickInit( int joy_num ) {
return( joystick_fd ); return( joystick_fd );
#else #else
return( 0 ); return( 1 );
#endif #endif
} }
@ -256,12 +256,16 @@ int fgJoystickRead( double *joy_x, double *joy_y, int *joy_b1, int *joy_b2 )
/* $Log$ /* $Log$
/* Revision 1.4 1998/02/03 23:20:20 curt /* Revision 1.5 1998/02/12 21:59:44 curt
/* Lots of little tweaks to fix various consistency problems discovered by /* Incorporated code changes contributed by Charlie Hotchkiss
/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper /* <chotchkiss@namg.us.anritsu.com>
/* passed arguments along to the real printf(). Also incorporated HUD changes
/* by Michele America.
/* /*
* 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 * Revision 1.3 1998/01/27 00:47:54 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code. * system and commandline/config file processing code.

View file

@ -28,13 +28,13 @@
#define _GLUTKEY_H #define _GLUTKEY_H
#ifdef GLUT #ifdef WIN32
#include <GL/glut.h> # include <windows.h>
#elif TIGER
/* assumes -I/usr/include/mesa in compile command */
#include "gltk.h"
#endif #endif
#include <GL/glut.h>
#include <XGL/xgl.h>
/* Handle keyboard events */ /* Handle keyboard events */
void GLUTkey(unsigned char k, int x, int y); void GLUTkey(unsigned char k, int x, int y);
void GLUTspecialkey(int k, int x, int y); void GLUTspecialkey(int k, int x, int y);
@ -44,9 +44,13 @@ void GLUTspecialkey(int k, int x, int y);
/* $Log$ /* $Log$
/* Revision 1.6 1998/01/22 02:59:36 curt /* Revision 1.7 1998/02/12 21:59:44 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H /* 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 * Revision 1.5 1997/07/23 21:52:23 curt
* Put comments around the text after an #endif for increased portability. * Put comments around the text after an #endif for increased portability.
* *

View file

@ -32,11 +32,14 @@
#include <XGL/xgl.h> #include <XGL/xgl.h>
#include <stdio.h> #include <stdio.h>
#include <getopt.h>
#include <Main/GLUTkey.h> #include <Main/GLUTkey.h>
#include <Main/fg_init.h> #include <Main/fg_init.h>
#include <Main/fg_debug.h> #include <Main/fg_debug.h>
#include <Main/fg_getopt.h>
#include <Main/views.h> #include <Main/views.h>
#include <Include/cmdargs.h> // Line to command line arguments
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
#include <Include/general.h> #include <Include/general.h>
@ -82,21 +85,114 @@ int show_hud;
/* Yet another other hack. Used for my prototype instrument code. (Durk) */ /* Yet another other hack. Used for my prototype instrument code. (Durk) */
int displayInstruments; 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 * fgInitVisuals() -- Initialize various GL/view parameters
**************************************************************************/ **************************************************************************/
static void fgInitVisuals( void ) { static void fgInitVisuals( void ) {
struct fgLIGHT *l; struct fgLIGHT *l;
struct fgTIME *t;
struct fgWEATHER *w; struct fgWEATHER *w;
l = &cur_light_params; l = &cur_light_params;
t = &cur_time_params;
w = &current_weather; w = &current_weather;
/* xglDisable( GL_DITHER ); */ /* xglDisable( GL_DITHER ); */
/* If enabled, normal vectors specified with glNormal are scaled /* If enabled, normal vectors specified with glNormal are scaled
@ -125,12 +221,12 @@ static void fgInitVisuals( void ) {
static void fgUpdateViewParams( void ) { static void fgUpdateViewParams( void ) {
fgFLIGHT *f; fgFLIGHT *f;
struct fgLIGHT *l; struct fgLIGHT *l;
struct fgTIME *t; // struct fgTIME *t;
struct fgVIEW *v; struct fgVIEW *v;
f = current_aircraft.flight; f = current_aircraft.flight;
l = &cur_light_params; l = &cur_light_params;
t = &cur_time_params; // t = &cur_time_params;
v = &current_view; v = &current_view;
fgViewUpdate(f, v, l); fgViewUpdate(f, v, l);
@ -306,9 +402,7 @@ static void fgRenderFrame( void ) {
fgUpdateInstrViewParams(); fgUpdateInstrViewParams();
} }
#ifdef GLUT xglutSwapBuffers();
xglutSwapBuffers();
#endif
} }
@ -575,84 +669,129 @@ static void fgReshape( int width, int height ) {
int main( int argc, char *argv[] ) { int main( int argc, char *argv[] ) {
fgFLIGHT *f; fgFLIGHT *f;
int parse_result; // Used in command line argument.
f = current_aircraft.flight; 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); printf("Flight Gear: Version %s\n\n", VERSION);
/********************************************************************** /*********************************************************************
* Initialize the Window/Graphics environment. * Initialize the Window/Graphics environment.
**********************************************************************/ **********************************************************************/
#ifdef GLUT /* initialize GLUT */
/* initialize GLUT */ xglutInit(&argc, argv);
xglutInit(&argc, argv);
/* Define Display Parameters */ /* Define Display Parameters */
xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
/* Define initial window size */ /* Define initial window size */
xglutInitWindowSize(640, 480); xglutInitWindowSize(640, 480);
/* Initialize windows */ /* Initialize windows */
xglutCreateWindow("Flight Gear"); xglutCreateWindow("Flight Gear");
#endif
/* This is the general house keeping init routine */ // xglutInit above will extract all non-general program command line.
fgInitGeneral(); // We only need wory about our own.
/* This is the top level init routine which calls all the other parse_result = getargs( argc, argv, OptsDefined, CmdLineOptions, NULL);
* subsystem initialization routines. If you are adding a
* subsystem to flight gear, its initialization call should
* located in this routine.*/
fgInitSubsystems();
/* setup view parameters, only makes GL calls */ switch( parse_result ) {
fgInitVisuals(); case ALLDONE:
break;
if ( use_signals ) { case HELP:
/* init timer routines, signals, etc. Arrange for an alarm print_desc( OptsDefined, CmdLineOptions );
signal to be generated, etc. */ exit(0);
fgInitTimeDepCalcs();
case INVALID:
default:
printf( "Flight Gear: Command line invalid.");
exit(0);
} }
/********************************************************************** // Deal with the effects of options no set by manipulating the command
* Initialize the Event Handlers. // line, or possibly set to invalid states.
**********************************************************************/
#ifdef GLUT if(( viewArg >= 0) && (viewArg < 1)) {
/* call fgReshape() on window resizes */ show_hud = viewArg; // For now view_mode TRUE - no HUD, else show_hud.
xglutReshapeFunc( fgReshape ); } else {
show_hud = DefaultViewMode;
}
/* call key() on keyboard event */ // All other command line option responses are handled in the various
xglutKeyboardFunc( GLUTkey ); // initialization routines (or ignored if not implemented.
glutSpecialFunc( GLUTspecialkey );
/* call fgMainLoop() whenever there is nothing else to do */ // This is the general house keeping init routine. It initializes the
xglutIdleFunc( fgMainLoop ); // debug trail scheme and then any other stuff.
/* draw the scene */ if( !fgInitGeneral()) {
xglutDisplayFunc( fgRenderFrame );
/* pass control off to the GLUT event handler */ // This is the top level init routine which calls all the other
glutMainLoop(); // subsystem initialization routines. If you are adding a
#endif // subsystem to flight gear, its initialization call should
// located in this routine.
if( !fgInitSubsystems()) {
// 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); return(0);
} }
#ifdef __SUNPRO_CC #ifdef __SUNPRO_CC
extern "C" { extern "C" {
void __eprintf( void ) { void __eprintf( void ) {
}
} }
}
#endif #endif
/* $Log$ /* $Log$
/* Revision 1.60 1998/02/11 02:50:40 curt /* Revision 1.61 1998/02/12 21:59:46 curt
/* Minor changes. /* 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 * Revision 1.59 1998/02/09 22:56:54 curt
* Removed "depend" files from cvs control. Other minor make tweaks. * Removed "depend" files from cvs control. Other minor make tweaks.
* *

View file

@ -25,7 +25,7 @@
TARGET = fg-$(FG_VERSION) 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 \ FGLIBS = -lAircraft -lAstro -lCockpit -lControls -lFlight \
-lJoystick -lLaRCsim -lSlew -lScenery -lTime -lWeather -lMath \ -lJoystick -lLaRCsim -lSlew -lScenery -lTime -lWeather -lMath \
@ -34,8 +34,7 @@ FGLIBS = -lAircraft -lAstro -lCockpit -lControls -lFlight \
LCDEFS = -DGLUT LCDEFS = -DGLUT
LLDFLAGS = LLDFLAGS =
LDLIBS = $(FGLIBS) $(FG_DEBUG_LIBS) \ LDLIBS = $(FGLIBS) $(FG_DEBUG_LIBS) $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm
$(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm
include $(FG_ROOT_SRC)/commondefs include $(FG_ROOT_SRC)/commondefs
@ -52,6 +51,10 @@ include $(COMMONRULES)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# $Log$ # $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 # Revision 1.47 1998/02/09 22:56:56 curt
# Removed "depend" files from cvs control. Other minor make tweaks. # Removed "depend" files from cvs control. Other minor make tweaks.
# #

View file

@ -23,21 +23,21 @@
**************************************************************************/ **************************************************************************/
#include <string.h> #include <string.h>
#include <Main/fg_debug.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
static int fg_DebugSem = 1; #include <Include/cmdargs.h> // Line to command line arguments
static fgDebugClass fg_DebugClass = FG_ALL; #include <Main/fg_debug.h>
static fgDebugPriority fg_DebugPriority = FG_INFO;
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; static fgDebugCallback fg_DebugCallback = NULL;
#ifndef __CYGWIN32__ FILE *fg_DebugOutput = NULL; // Visibility needed for command line processor.
static FILE *fg_DebugOutput = stderr; // This can be set to a FILE from the command
#else /* __CYGWIN32__ */ // line. If not, it will be set to stderr.
static FILE *fg_DebugOutput = NULL;
#endif /* __CYGWIN32 */
/* TODO: Actually make this thing thread safe */ /* TODO: Actually make this thing thread safe */
#ifdef USETHREADS #ifdef USETHREADS
@ -77,28 +77,59 @@ static fgDebugClass fgDebugStrToClass( char *str );
/* fgInitDebug =============================================================*/ /* fgInitDebug =============================================================*/
void fgInitDebug( void ) void fgInitDebug( void )
{ {
char *pszClass, *pszPrio; char *pszClass, *pszPrio, *pszFile;
#ifdef __CYGWIN32__ // Support for log file/alt debug output via command line, environment or
fg_DebugOutput = stderr; // reasonable default.
#endif /* __CYGWIN32 */
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+" );
}
}
if( !fg_DebugOutput ) { // If neither command line nor environment
fg_DebugOutput = stderr; // then we use the fallback position
}
FG_GRABDEBUGSEM; FG_GRABDEBUGSEM;
fg_DebugSem=fg_DebugSem; /* shut up GCC */ fg_DebugSem = fg_DebugSem; /* shut up GCC */
pszPrio = getenv( "FG_DEBUGPRIORITY" ); // Test command line option overridge of debug priority. If the value
if( pszPrio ) { // is in range (properly optioned) the we will override both defaults
fg_DebugPriority = atoi( pszPrio ); // and the environmental value.
fprintf( stderr, "fg_debug.c: Environment overrides default debug priority (%d)\n",
fg_DebugPriority );
}
pszClass = getenv( "FG_DEBUGCLASS" ); if ((priorityArgValue >= FG_BULK) && (priorityArgValue <= FG_ABORT)) {
if( pszClass ) { fg_DebugPriority = priorityArgValue;
fg_DebugClass = fgDebugStrToClass( pszClass ); }
fprintf( stderr, "fg_debug.c: Environment overrides default debug class (0x%08X)\n", else { // Either not set or out of range. We will not warn the user.
fg_DebugClass ); 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; FG_RELEASEDEBUGSEM;
} }
@ -108,7 +139,7 @@ fgDebugClass fgDebugStrToClass( char *str )
{ {
char *hex = "0123456789ABCDEF"; char *hex = "0123456789ABCDEF";
char *hexl = "0123456789abcdef"; char *hexl = "0123456789abcdef";
char *pt, *p, *ph, ps=1; char *pt, *p, *ph, ps = 1;
unsigned int val = 0, i; unsigned int val = 0, i;
if( str == NULL ) { if( str == NULL ) {
@ -195,13 +226,16 @@ int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... )
va_list ap; va_list ap;
int ret = 0; 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) ) { if( !(dbg_class & fg_DebugClass) || (prio < fg_DebugPriority) ) {
FG_RELEASEDEBUGSEM; return ret; // Its zero anyway. But we might think about changing
return 0; // it upon some error condition?
} }
FG_GRABDEBUGSEM;
/* ret = vsprintf( szOut, fmt, (&fmt+1)); (but it didn't work, thus ... */ /* ret = vsprintf( szOut, fmt, (&fmt+1)); (but it didn't work, thus ... */
va_start (ap, fmt); va_start (ap, fmt);
ret = vsprintf( szOut, fmt, ap); ret = vsprintf( szOut, fmt, ap);
@ -224,3 +258,6 @@ int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... )
return ret; return ret;
} }
// Revision history?
//

View file

@ -31,7 +31,7 @@
/* NB: To add a dbg_class, add it here, and add it to the structure /* NB: To add a dbg_class, add it here, and add it to the structure
in fg_debug.c in fg_debug.c
*/ */
typedef enum { typedef enum{
FG_NONE = 0x00000000, FG_NONE = 0x00000000,
FG_TERRAIN = 0x00000001, FG_TERRAIN = 0x00000001,
@ -45,20 +45,21 @@ typedef enum {
FG_MATH = 0x00000100, FG_MATH = 0x00000100,
FG_EVENT = 0x00000200, FG_EVENT = 0x00000200,
FG_AIRCRAFT= 0x00000400, FG_AIRCRAFT= 0x00000400,
FG_UNDEFD = 0x00001000, // For range checking
FG_ALL = 0xFFFFFFFF FG_ALL = 0xFFFFFFFFL // -1!
} fgDebugClass; } fgDebugClass;
/* NB: To add a priority, add it here. /* NB: To add a priority, add it here.
*/ */
typedef enum { typedef enum {
FG_BULK, /* For frequent messages */ FG_BULK, /* For frequent messages */
FG_DEBUG, /* Less frequent debug type messages */ FG_DEBUG, /* Less frequent debug type messages */
FG_INFO, /* Informatory messages */ FG_INFO, /* Informatory messages */
FG_WARN, /* Possible impending problem */ FG_WARN, /* Possible impending problem */
FG_ALERT, /* Very possible impending problem */ FG_ALERT, /* Very possible impending problem */
FG_EXIT, /* Problem (no core) */ FG_EXIT, /* Problem (no core) */
FG_ABORT /* Abandon ship (core) */ FG_ABORT /* Abandon ship (core) */
} fgDebugPriority; } fgDebugPriority;
/* Initialize the debuggin stuff. */ /* Initialize the debuggin stuff. */
@ -122,9 +123,19 @@ void fgSetDebugOutput( FILE *out );
processing of the message.** Only one callback may be installed at a processing of the message.** Only one callback may be installed at a
time. 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 ); 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 */ #endif /* _FG_DEBUG_H */

View file

@ -30,6 +30,7 @@
#include <Main/fg_init.h> #include <Main/fg_init.h>
#include <Main/views.h> #include <Main/views.h>
#include <Include/cmdargs.h>
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
#include <Include/general.h> #include <Include/general.h>
@ -52,11 +53,11 @@
extern int show_hud; /* HUD state */ extern int show_hud; /* HUD state */
extern int displayInstruments; extern int displayInstruments;
extern const char *default_root;
/* General house keeping initializations */ /* General house keeping initializations */
void fgInitGeneral( void ) { int fgInitGeneral( void ) {
struct fgGENERAL *g; struct fgGENERAL *g;
g = &general; g = &general;
@ -69,23 +70,37 @@ void fgInitGeneral( void ) {
/* seed the random number generater */ /* seed the random number generater */
fg_srandom(); fg_srandom();
/* determine the fg root path */ // determine the fg root path. The command line parser getargs() will
if ( (g->root_dir = getenv("FG_ROOT")) == NULL ) { // fill in a root directory if the option was used.
/* environment variable not defined */
fgPrintf(FG_GENERAL, FG_EXIT, "FG_ROOT needs to be defined! " if( !(g->root_dir) ) {
"See the documentation.\n"); // 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); 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 // This is the top level init routine which calls all the other
* initialization routines. If you are adding a subsystem to flight // initialization routines. If you are adding a subsystem to flight
* gear, its initialization call should located in this routine.*/ // 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; double cur_elev;
// Ok will be flagged only if we get EVERYTHING done.
int ret_val = 1 /* TRUE */;
fgFLIGHT *f; fgFLIGHT *f;
struct fgLIGHT *l; struct fgLIGHT *l;
struct fgTIME *t; struct fgTIME *t;
@ -105,7 +120,8 @@ void fgInitSubsystems( void ) {
/* Must happen before any of the flight model or control /* Must happen before any of the flight model or control
* parameters are set */ * parameters are set */
fgAircraftInit();
fgAircraftInit(); // In the future this might not be the case.
f = current_aircraft.flight; f = current_aircraft.flight;
/* Globe Aiport, AZ */ /* Globe Aiport, AZ */
@ -180,11 +196,17 @@ void fgInitSubsystems( void ) {
/* FG_Runway_altitude = 5000.0; */ /* FG_Runway_altitude = 5000.0; */
/* FG_Altitude = FG_Runway_altitude + 3.758099; */ /* FG_Altitude = FG_Runway_altitude + 3.758099; */
/* Initial Position: (GCN) Grand Canyon Airport, AZ */ // Initial Position: (GCN) Grand Canyon Airport, AZ
FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD; // FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD;
FG_Latitude = ( 35.9523539 ) * DEG_TO_RAD; // FG_Latitude = ( 35.9523539 ) * DEG_TO_RAD;
FG_Runway_altitude = 6606.0; // FG_Runway_altitude = 6606.0;
FG_Altitude = FG_Runway_altitude + 3.758099; // 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 */ /* A random test position */
/* FG_Longitude = ( 88128.00 / 3600.0 ) * DEG_TO_RAD; */ /* FG_Longitude = ( 88128.00 / 3600.0 ) * DEG_TO_RAD; */
@ -261,44 +283,51 @@ void fgInitSubsystems( void ) {
FG_EVENT_READY, 120000 ); FG_EVENT_READY, 120000 );
/* Initialize the Cockpit subsystem */ /* Initialize the Cockpit subsystem */
if( fgCockpitInit( &current_aircraft ) == NULL ) { if( fgCockpitInit( &current_aircraft )) {
// Cockpit initialized ok.
} else {
fgPrintf( FG_GENERAL, FG_EXIT, "Error in Cockpit initialization!\n" ); 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); fgSolarSystemInit(*t);
/* Initialize the Stars subsystem */ // Initialize the Stars subsystem
fgStarsInit(); 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); fgEventRegister("fgPlanetsInit()", fgPlanetsInit, FG_EVENT_READY, 600000);
/* Initialize the sun's position */ // Initialize the sun's position
fgEventRegister( "fgSunInit()", fgSunInit, FG_EVENT_READY, 60000 ); fgEventRegister("fgSunInit()", fgSunInit, FG_EVENT_READY, 60000 );
/* Intialize the moon's position */ // Intialize the moon's position
fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 ); fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 );
/* Initialize the "sky" */ // Initialize the "sky"
fgSkyInit(); fgSkyInit();
/* Initialize the Scenery Management subsystem */ // Initialize the Scenery Management subsystem
fgTileMgrInit(); if( fgTileMgrInit() ) {
/* fgSceneryInit(); */ // Load the local scenery data
fgTileMgrUpdate();
} else {
fgPrintf( FG_GENERAL, FG_EXIT,
"Error in Tile Manager initialization!\n" );
}
/* Tell the Scenery Management system where we are so it can load // I'm just sticking this here for now, it should probably move
* the correct scenery data */ // eventually
fgTileMgrUpdate(); // cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
/* fgSceneryUpdate(FG_Latitude, FG_Longitude, FG_Altitude); */ // FG_Latitude * RAD_TO_DEG * 3600.0); */
// fgPrintf( FG_GENERAL, FG_INFO,
// "True ground elevation is %.2f meters here.\n",
// cur_elev); */
/* 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; cur_elev = FG_Runway_altitude * FEET_TO_METER;
if ( cur_elev > -9990.0 ) { if ( cur_elev > -9990.0 ) {
FG_Runway_altitude = cur_elev * METER_TO_FEET; FG_Runway_altitude = cur_elev * METER_TO_FEET;
@ -307,36 +336,49 @@ void fgInitSubsystems( void ) {
if ( FG_Altitude < FG_Runway_altitude ) { if ( FG_Altitude < FG_Runway_altitude ) {
FG_Altitude = FG_Runway_altitude + 3.758099; FG_Altitude = FG_Runway_altitude + 3.758099;
} }
fgPrintf(FG_GENERAL, FG_INFO, fgPrintf(FG_GENERAL, FG_INFO,
"Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n", "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
FG_Altitude * FEET_TO_METER); FG_Altitude * FEET_TO_METER);
/* end of thing that I just stuck in that I should probably move */ /* end of thing that I just stuck in that I should probably move */
/* Initialize the flight model subsystem data structures base on /* Initialize the flight model subsystem data structures base on
* above values */ * above values */
fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ ); fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
/* To HUD or not to HUD */ // To HUD or not to HUD - Now a command line issue
show_hud = 0; // show_hud = 0;
/* Let's show the instrument panel */ // Let's not show the instrument panel
displayInstruments = 0; displayInstruments = 0;
/* Joystick support */ // Joystick support
fgJoystickInit( 0 ); 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(); fgSkyColorsInit();
ret_val = 0;
fgPrintf(FG_GENERAL, FG_INFO,"\n"); fgPrintf(FG_GENERAL, FG_INFO,"\n");
return ret_val;
} }
/* $Log$ /* $Log$
/* Revision 1.43 1998/02/11 02:50:40 curt /* Revision 1.44 1998/02/12 21:59:50 curt
/* Minor changes. /* 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 * Revision 1.42 1998/02/09 22:56:58 curt
* Removed "depend" files from cvs control. Other minor make tweaks. * Removed "depend" files from cvs control. Other minor make tweaks.
* *

View file

@ -28,22 +28,26 @@
#define _FG_INIT_H #define _FG_INIT_H
/* General house keeping initializations */ // General house keeping initializations
void fgInitGeneral( void ); int fgInitGeneral ( void );
/* This is the top level init routine which calls all the other // This is the top level init routine which calls all the other
* initialization routines. If you are adding a subsystem to flight // initialization routines. If you are adding a subsystem to flight
* gear, its initialization call should located in this routine.*/ // gear, its initialization call should located in this routine.
void fgInitSubsystems( void ); int fgInitSubsystems( void );
#endif /* _FG_INIT_H */ #endif /* _FG_INIT_H */
/* $Log$ /* $Log$
/* Revision 1.2 1998/01/22 02:59:38 curt /* Revision 1.3 1998/02/12 21:59:50 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H /* 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 * Revision 1.1 1997/08/23 01:46:20 curt
* Initial revision. * Initial revision.
* *

View file

@ -65,10 +65,11 @@ ConvertUint(unsigned *array, unsigned int length) {
static ImageRec *ImageOpen(char *fileName) static ImageRec *ImageOpen(char *fileName)
{ {
union { union {
int testWord; int testWord;
char testByte[4]; char testByte[4];
} endianTest; } endianTest;
ImageRec *image; ImageRec *image;
int swapFlag; int swapFlag;
int x; int x;
@ -86,7 +87,7 @@ static ImageRec *ImageOpen(char *fileName)
exit(1); exit(1);
} }
if ((image->file = fopen(fileName, "rb")) == NULL) { if ((image->file = fopen(fileName, "rb")) == NULL) {
return NULL; return NULL;
} }
fread(image, 1, 12, image->file); fread(image, 1, 12, image->file);

View file

@ -53,8 +53,9 @@ int tiles[FG_LOCAL_X_Y];
/* Initialize the Tile Manager subsystem */ /* Initialize the Tile Manager subsystem */
void fgTileMgrInit( void ) { int fgTileMgrInit( void ) {
fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n"); fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
return 1;
} }
@ -75,7 +76,7 @@ void fgTileMgrLoadTile( struct fgBUCKET *p, int *index) {
/* given the current lon/lat, fill in the array of local chunks. If /* 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. */ * the chunk isn't already in the cache, then read it from disk. */
void fgTileMgrUpdate( void ) { int fgTileMgrUpdate( void ) {
fgFLIGHT *f; fgFLIGHT *f;
struct fgBUCKET p1, p2; struct fgBUCKET p1, p2;
static struct fgBUCKET p_last = {-1000, 0, 0, 0}; static struct fgBUCKET p_last = {-1000, 0, 0, 0};
@ -97,7 +98,7 @@ void fgTileMgrUpdate( void ) {
fgPrintf( FG_TERRAIN, FG_DEBUG, "First time through ... \n"); fgPrintf( FG_TERRAIN, FG_DEBUG, "First time through ... \n");
fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n", fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n",
p1.lon, p1.lat, p1.x, p1.y); p1.lon, p1.lat, p1.x, p1.y);
/* wipe tile cache */ /* wipe tile cache */
fgTileCacheInit(); fgTileCacheInit();
@ -151,8 +152,7 @@ void fgTileMgrUpdate( void ) {
} }
/* load in new column */ /* load in new column */
fgBucketOffset(&p_last, &p2, i - dw, dh + 1); fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
fgTileMgrLoadTile(&p2, fgTileMgrLoadTile(&p2, &tiles[((FG_LOCAL_Y-1)*FG_LOCAL_Y) + i]);
&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) ) ) { ( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
@ -172,6 +172,7 @@ void fgTileMgrUpdate( void ) {
p_last.lat = p1.lat; p_last.lat = p1.lat;
p_last.x = p1.x; p_last.x = p1.x;
p_last.y = p1.y; p_last.y = p1.y;
return 1;
} }
@ -224,8 +225,9 @@ void fgTileMgrRender( void ) {
/* $Log$ /* $Log$
/* Revision 1.15 1998/02/11 02:50:44 curt /* Revision 1.16 1998/02/12 21:59:53 curt
/* Minor changes. /* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/* /*
* Revision 1.14 1998/02/09 21:30:19 curt * Revision 1.14 1998/02/09 21:30:19 curt
* Fixed a nagging problem with terrain tiles not "quite" matching up perfectly. * Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.

View file

@ -29,12 +29,12 @@
/* Initialize the Tile Manager subsystem */ /* Initialize the Tile Manager subsystem */
void fgTileMgrInit( void ); int fgTileMgrInit( void );
/* given the current lon/lat, fill in the array of local chunks. If /* 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. */ * 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 */ /* Render the local tiles --- hack, hack, hack */
@ -45,9 +45,13 @@ void fgTileMgrRender( void );
/* $Log$ /* $Log$
/* Revision 1.4 1998/01/22 02:59:42 curt /* Revision 1.5 1998/02/12 21:59:53 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H /* 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 * Revision 1.3 1998/01/19 18:40:38 curt
* Tons of little changes to clean up the code and to remove fatal errors * Tons of little changes to clean up the code and to remove fatal errors
* when building with the c++ compiler. * when building with the c++ compiler.

View file

@ -2,6 +2,8 @@
| Todo | Todo
-------------------------------------------------------------------------- --------------------------------------------------------------------------
1/12/98 - Fix time problem on win32
12/29/97 - View frustum culling 12/29/97 - View frustum culling
1/5/98 - Create a development "roadmap" 1/5/98 - Create a development "roadmap"

View file

@ -43,7 +43,7 @@ TAR = tar
# #
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\" GLOBAL_CFLAGS = -Wall -DVERSION=\"$(FG_VERSION)\"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -85,9 +85,7 @@ GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Linux/Mesa with the GLUT toolkit # Linux/Mesa with the GLUT toolkit
# #
INTERFACE_FLAGS = -DGLUT
INTERFACE_LIBS = -lglut INTERFACE_LIBS = -lglut
INTERFACE_FILES = GLUTmain.c GLUTkey.c
MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL
X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11 X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11
GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS) GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
@ -100,9 +98,7 @@ EXT =
# (Surprisingly, this also works on our SunOS 4.x machine with the # (Surprisingly, this also works on our SunOS 4.x machine with the
# way we have Mesa & Glut installed.) # way we have Mesa & Glut installed.)
# #
# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = -lglut # INTERFACE_LIBS = -lglut
# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11 # GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11
# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) # FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS)
# EXT = # EXT =
@ -113,9 +109,7 @@ EXT =
# Sun/Solaris with the GLUT toolkit # Sun/Solaris with the GLUT toolkit
# #
# VERSION=\"$(VERSION)\" # VERSION=\"$(VERSION)\"
# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = -lglut # INTERFACE_LIBS = -lglut
# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -L/opt/X11R6/lib -lGLU -lGL -lXext -lXmu -lXi -lX11 -lsocket # GRAPHICS_LIBS = -L/opt/X11R6/lib -lGLU -lGL -lXext -lXmu -lXi -lX11 -lsocket
# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) # FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS)
# EXT = # EXT =
@ -125,9 +119,7 @@ EXT =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Cygnus Win32 (gcc based) with a static version of the GLUT toolkit # Cygnus Win32 (gcc based) with a static version of the GLUT toolkit
# #
# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = ../Win32/libglut.a # INTERFACE_LIBS = ../Win32/libglut.a
# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -lglu32 -lopengl32 -luser32 -lgdi32 # GRAPHICS_LIBS = -lglu32 -lopengl32 -luser32 -lgdi32
# FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) -DWIN32 -DUSE_RAND # FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) -DWIN32 -DUSE_RAND
# EXT = .exe # EXT = .exe