Incorporated code changes contributed by Charlie Hotchkiss
<chotchkiss@namg.us.anritsu.com>
This commit is contained in:
parent
9c90c31a49
commit
913fe75558
23 changed files with 750 additions and 404 deletions
|
@ -39,7 +39,7 @@ fgAIRCRAFT current_aircraft;
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -64,10 +64,14 @@ void fgAircraftOutputCurrent(fgAIRCRAFT *a) {
|
|||
|
||||
|
||||
/* $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.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -119,49 +121,51 @@ 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");
|
||||
g = &general;
|
||||
path[0] = '\0';
|
||||
strcat(path, g->root_dir);
|
||||
strcat(path, "/Scenery/");
|
||||
strcat(path, "Planets.dat");
|
||||
|
||||
if ( (data = fopen(path, "r")) == NULL )
|
||||
{
|
||||
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);
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,12 +187,16 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
|
|||
|
||||
|
||||
/* $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
|
||||
*
|
||||
|
|
|
@ -73,7 +73,7 @@ double fgCalcEccAnom(double M, double e);
|
|||
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);
|
||||
|
||||
|
||||
|
@ -81,9 +81,13 @@ 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
|
||||
*
|
||||
|
|
|
@ -204,12 +204,16 @@ void fgPlanetsRender( void ) {
|
|||
|
||||
|
||||
/* $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
|
||||
*
|
||||
|
|
|
@ -32,17 +32,21 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
|
|||
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
|
||||
*
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
|
||||
/* Initialize the Star Management Subsystem */
|
||||
void fgStarsInit( void ) {
|
||||
int fgStarsInit( void ) {
|
||||
FILE *fd;
|
||||
struct fgGENERAL *g;
|
||||
/* struct CelestialCoord pltPos; */
|
||||
|
@ -87,7 +87,7 @@ void fgStarsInit( void ) {
|
|||
if ( (fd = fopen(path, "r")) == NULL ) {
|
||||
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);
|
||||
|
@ -129,20 +129,20 @@ void fgStarsInit( void ) {
|
|||
&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;
|
||||
|
@ -153,7 +153,7 @@ void fgStarsInit( void ) {
|
|||
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);*/
|
||||
|
@ -162,7 +162,7 @@ void fgStarsInit( void ) {
|
|||
50000.0 * sin(declination) );
|
||||
|
||||
count++;
|
||||
} /* if valid line */
|
||||
} // valid line
|
||||
|
||||
} /* while */
|
||||
|
||||
|
@ -210,6 +210,8 @@ void fgStarsInit( void ) {
|
|||
|
||||
max_stars /= 2;
|
||||
}
|
||||
|
||||
return 1; // OK, we got here because initialization worked.
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,9 +255,13 @@ void fgStarsRender( void ) {
|
|||
|
||||
|
||||
/* $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
|
||||
*
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#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 );
|
||||
|
@ -44,9 +44,13 @@ extern struct fgTIME cur_time_params;
|
|||
|
||||
|
||||
/* $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.
|
||||
|
|
17
Astro/sun.c
17
Astro/sun.c
|
@ -114,6 +114,7 @@ void fgSunInit( void ) {
|
|||
|
||||
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",
|
||||
sunPos.RightAscension, sunPos.Declination);
|
||||
|
@ -156,10 +157,10 @@ void fgSunInit( void ) {
|
|||
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);
|
||||
"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 );
|
||||
|
@ -195,9 +196,13 @@ void fgSunRender( void ) {
|
|||
|
||||
|
||||
/* $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.
|
||||
|
|
197
Cockpit/hud.c
197
Cockpit/hud.c
|
@ -33,8 +33,8 @@
|
|||
#include <string.h>
|
||||
|
||||
#ifndef WIN32
|
||||
# include <values.h> /* for MAXINT */
|
||||
#endif /* not WIN32 */
|
||||
# include <values.h> // for MAXINT
|
||||
#endif //
|
||||
|
||||
#include "hud.h"
|
||||
|
||||
|
@ -45,7 +45,6 @@
|
|||
#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>
|
||||
|
||||
|
@ -216,53 +215,61 @@ static void drawscale( HUD_scale * pscale )
|
|||
|
||||
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,
|
||||
|
@ -285,7 +292,7 @@ static void drawscale( HUD_scale * pscale )
|
|||
pscale->scr_pos-6 );
|
||||
|
||||
}
|
||||
else
|
||||
else {
|
||||
if( pscale->orientation == BOTTOM )
|
||||
{
|
||||
drawOneLine( pscale->scr_min,
|
||||
|
@ -303,58 +310,61 @@ static void drawscale( HUD_scale * pscale )
|
|||
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 )
|
||||
{
|
||||
|
@ -402,10 +412,12 @@ static void drawladder( HUD_ladder *ladder )
|
|||
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;
|
||||
|
@ -442,10 +454,12 @@ static void drawladder( HUD_ladder *ladder )
|
|||
}
|
||||
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;
|
||||
|
@ -479,10 +493,12 @@ static void drawladder( HUD_ladder *ladder )
|
|||
|
||||
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) -\
|
||||
|
@ -571,14 +587,12 @@ static void drawhorizon( HUD_horizon *horizon )
|
|||
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
|
||||
// drawControlSurfaces()
|
||||
// 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 )
|
||||
{
|
||||
int x_ini, y_ini;
|
||||
|
@ -711,12 +725,12 @@ static void drawlabel( HUD_label *label )
|
|||
|
||||
|
||||
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;
|
||||
|
@ -767,7 +781,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
|
|||
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.
|
||||
|
||||
|
@ -784,7 +798,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
|
|||
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 );
|
||||
}
|
||||
|
@ -1011,6 +1025,50 @@ Hptr fgHUDAddLadder( Hptr 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, \
|
||||
|
@ -1073,9 +1131,8 @@ void fgUpdateHUD( Hptr hud ) {
|
|||
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 ) {
|
||||
|
@ -1100,6 +1157,7 @@ void fgUpdateHUD( Hptr hud ) {
|
|||
|
||||
case HUDcontrols:
|
||||
drawControlSurfaces( (pHUDControlSurface) phud_instr->instr );
|
||||
break;
|
||||
|
||||
default:; // Ignore anything you don't know about.
|
||||
}
|
||||
|
@ -1117,8 +1175,9 @@ void fgUpdateHUD( Hptr hud ) {
|
|||
|
||||
|
||||
/* $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.
|
||||
|
|
|
@ -32,14 +32,17 @@
|
|||
#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
|
||||
|
@ -50,7 +53,7 @@
|
|||
#define NOLIMIT 8
|
||||
#define ROUNDROB 9
|
||||
|
||||
/* Label constants */
|
||||
// Label constants
|
||||
#define SMALL 1
|
||||
#define LARGE 2
|
||||
#define BLINK 3
|
||||
|
@ -59,7 +62,7 @@
|
|||
#define CENTER_JUST 6
|
||||
#define RIGHT_JUST 7
|
||||
|
||||
/* Ladder constants */
|
||||
// Ladder constants
|
||||
#define NONE 1
|
||||
#define UPPER_LEFT 2
|
||||
#define UPPER_CENTER 3
|
||||
|
@ -73,12 +76,12 @@
|
|||
#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
|
||||
|
@ -89,7 +92,7 @@
|
|||
// #define HUD_H_BOTTOM 2
|
||||
|
||||
|
||||
/* Ladder sub-types */
|
||||
// Ladder sub-types
|
||||
// #define HUD_LIM 1
|
||||
// #define HUD_NOLIM 2
|
||||
// #define HUD_CIRC 3
|
||||
|
@ -203,7 +206,7 @@ typedef struct {
|
|||
|
||||
// Removed union HUD_instr_data to evolve this to oop code.
|
||||
|
||||
enum hudinstypes { HUDno_instr,
|
||||
typedef enum{ HUDno_instr,
|
||||
HUDscale,
|
||||
HUDcirc_scale,
|
||||
HUDladder,
|
||||
|
@ -211,10 +214,10 @@ enum hudinstypes { HUDno_instr,
|
|||
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
|
||||
|
@ -312,12 +315,12 @@ void fgUpdateHUD ( Hptr hud );
|
|||
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
|
||||
|
|
|
@ -208,7 +208,7 @@ int fgJoystickInit( int joy_num ) {
|
|||
|
||||
return( joystick_fd );
|
||||
#else
|
||||
return( 0 );
|
||||
return( 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -256,12 +256,16 @@ int fgJoystickRead( double *joy_x, double *joy_y, int *joy_b1, int *joy_b2 )
|
|||
|
||||
|
||||
/* $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.
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
#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);
|
||||
|
@ -44,9 +44,13 @@ 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.
|
||||
*
|
||||
|
|
245
Main/GLUTmain.c
245
Main/GLUTmain.c
|
@ -32,11 +32,14 @@
|
|||
#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>
|
||||
|
||||
|
@ -82,21 +85,114 @@ int show_hud;
|
|||
/* 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
|
||||
|
@ -125,12 +221,12 @@ static void fgInitVisuals( void ) {
|
|||
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);
|
||||
|
@ -306,9 +402,7 @@ static void fgRenderFrame( void ) {
|
|||
fgUpdateInstrViewParams();
|
||||
}
|
||||
|
||||
#ifdef GLUT
|
||||
xglutSwapBuffers();
|
||||
#endif
|
||||
xglutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
|
@ -575,84 +669,129 @@ static void fgReshape( int width, int height ) {
|
|||
|
||||
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.
|
||||
|
||||
#ifdef GLUT
|
||||
/* call fgReshape() on window resizes */
|
||||
xglutReshapeFunc( fgReshape );
|
||||
if(( viewArg >= 0) && (viewArg < 1)) {
|
||||
show_hud = viewArg; // For now view_mode TRUE - no HUD, else show_hud.
|
||||
} else {
|
||||
show_hud = DefaultViewMode;
|
||||
}
|
||||
|
||||
/* call key() on keyboard event */
|
||||
xglutKeyboardFunc( GLUTkey );
|
||||
glutSpecialFunc( GLUTspecialkey );
|
||||
// All other command line option responses are handled in the various
|
||||
// initialization routines (or ignored if not implemented.
|
||||
|
||||
/* call fgMainLoop() whenever there is nothing else to do */
|
||||
xglutIdleFunc( fgMainLoop );
|
||||
// This is the general house keeping init routine. It initializes the
|
||||
// debug trail scheme and then any other stuff.
|
||||
|
||||
/* draw the scene */
|
||||
xglutDisplayFunc( fgRenderFrame );
|
||||
if( !fgInitGeneral()) {
|
||||
|
||||
/* pass control off to the GLUT event handler */
|
||||
glutMainLoop();
|
||||
#endif
|
||||
// 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()) {
|
||||
|
||||
// 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.
|
||||
*
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
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 \
|
||||
|
@ -34,8 +34,7 @@ FGLIBS = -lAircraft -lAstro -lCockpit -lControls -lFlight \
|
|||
|
||||
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
|
||||
|
||||
|
@ -52,6 +51,10 @@ include $(COMMONRULES)
|
|||
|
||||
#---------------------------------------------------------------------------
|
||||
# $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.
|
||||
#
|
||||
|
|
|
@ -23,21 +23,21 @@
|
|||
**************************************************************************/
|
||||
|
||||
#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
|
||||
|
@ -77,28 +77,59 @@ static fgDebugClass fgDebugStrToClass( char *str );
|
|||
/* fgInitDebug =============================================================*/
|
||||
void fgInitDebug( void )
|
||||
{
|
||||
char *pszClass, *pszPrio;
|
||||
char *pszClass, *pszPrio, *pszFile;
|
||||
|
||||
#ifdef __CYGWIN32__
|
||||
fg_DebugOutput = stderr;
|
||||
#endif /* __CYGWIN32 */
|
||||
// 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+" );
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -108,7 +139,7 @@ fgDebugClass fgDebugStrToClass( char *str )
|
|||
{
|
||||
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 ) {
|
||||
|
@ -195,13 +226,16 @@ int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... )
|
|||
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);
|
||||
ret = vsprintf( szOut, fmt, ap);
|
||||
|
@ -224,3 +258,6 @@ int fgPrintf( fgDebugClass dbg_class, fgDebugPriority prio, char *fmt, ... )
|
|||
return ret;
|
||||
}
|
||||
|
||||
// Revision history?
|
||||
//
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
/* 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,
|
||||
|
@ -45,20 +45,21 @@ typedef enum {
|
|||
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. */
|
||||
|
@ -122,9 +123,19 @@ void fgSetDebugOutput( FILE *out );
|
|||
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 */
|
||||
|
||||
|
|
144
Main/fg_init.c
144
Main/fg_init.c
|
@ -30,6 +30,7 @@
|
|||
#include <Main/fg_init.h>
|
||||
#include <Main/views.h>
|
||||
|
||||
#include <Include/cmdargs.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Include/general.h>
|
||||
|
||||
|
@ -52,11 +53,11 @@
|
|||
|
||||
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;
|
||||
|
@ -69,23 +70,37 @@ void fgInitGeneral( void ) {
|
|||
/* 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;
|
||||
|
@ -105,7 +120,8 @@ void fgInitSubsystems( void ) {
|
|||
|
||||
/* 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 */
|
||||
|
@ -180,11 +196,17 @@ void fgInitSubsystems( void ) {
|
|||
/* 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; */
|
||||
|
@ -261,44 +283,51 @@ void fgInitSubsystems( void ) {
|
|||
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(); */
|
||||
// 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" );
|
||||
}
|
||||
|
||||
/* 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); */
|
||||
|
||||
/* 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;
|
||||
|
@ -307,36 +336,49 @@ void fgInitSubsystems( void ) {
|
|||
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);
|
||||
"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.
|
||||
*
|
||||
|
|
|
@ -28,22 +28,26 @@
|
|||
#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.
|
||||
*
|
||||
|
|
|
@ -65,10 +65,11 @@ ConvertUint(unsigned *array, unsigned int length) {
|
|||
|
||||
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;
|
||||
|
@ -86,7 +87,7 @@ static ImageRec *ImageOpen(char *fileName)
|
|||
exit(1);
|
||||
}
|
||||
if ((image->file = fopen(fileName, "rb")) == NULL) {
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fread(image, 1, 12, image->file);
|
||||
|
|
|
@ -53,8 +53,9 @@ int tiles[FG_LOCAL_X_Y];
|
|||
|
||||
|
||||
/* Initialize the Tile Manager subsystem */
|
||||
void fgTileMgrInit( void ) {
|
||||
int fgTileMgrInit( void ) {
|
||||
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
|
||||
* 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};
|
||||
|
@ -97,7 +98,7 @@ void fgTileMgrUpdate( void ) {
|
|||
|
||||
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);
|
||||
p1.lon, p1.lat, p1.x, p1.y);
|
||||
|
||||
/* wipe tile cache */
|
||||
fgTileCacheInit();
|
||||
|
@ -151,8 +152,7 @@ void fgTileMgrUpdate( void ) {
|
|||
}
|
||||
/* 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) ||
|
||||
( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
|
||||
|
@ -172,6 +172,7 @@ void fgTileMgrUpdate( void ) {
|
|||
p_last.lat = p1.lat;
|
||||
p_last.x = p1.x;
|
||||
p_last.y = p1.y;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,8 +225,9 @@ void fgTileMgrRender( void ) {
|
|||
|
||||
|
||||
/* $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.
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
|
||||
|
||||
/* 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 */
|
||||
|
@ -45,9 +45,13 @@ void fgTileMgrRender( void );
|
|||
|
||||
|
||||
/* $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.
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
| Todo
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
1/12/98 - Fix time problem on win32
|
||||
|
||||
12/29/97 - View frustum culling
|
||||
|
||||
1/5/98 - Create a development "roadmap"
|
||||
|
|
|
@ -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
|
||||
#
|
||||
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)
|
||||
|
@ -100,9 +98,7 @@ EXT =
|
|||
# (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 =
|
||||
|
@ -113,9 +109,7 @@ 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 =
|
||||
|
@ -125,9 +119,7 @@ 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
|
||||
|
|
Loading…
Reference in a new issue