// -rp- please use FG_MEM_COPY everywhere !
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
+// -dw- currently used glut has no game mode stuff
+# define GLUT_WRONG_VERSION
+
# elif (__MWERKS__ >= 0x0900) && __INTEL__
# error still to be supported...
# else
#endif // FG_INCOMPLETE_FUNCTIONAL
#endif // _COMPILER_H
-
#ifndef _FG_CALLBACK_HXX
#define _FG_CALLBACK_HXX
+// -dw- need size_t for params() function
+#ifdef __MWERKS__
+typedef unsigned long size_t;
+#endif
+
+
//-----------------------------------------------------------------------------
//
// Abstract base class for all FlightGear callbacks.
FGPath path( raw_path );
- return path.get_path();
+ return path.str();
}
// create a path based on "path"
FGPath::FGPath( const string p ) {
- path = fix_path( p );
+ set( p );
}
}
-// append to the existing path
+// set path
+void FGPath::set( const string p ) {
+ path = fix_path( p );
+}
+
+
+// append another piece to the existing path
void FGPath::append( const string p ) {
string part = fix_path( p );
path += part;
}
}
+
+
+// concatenate a string to the end of the path without inserting a
+// path separator
+void FGPath::concat( const string p ) {
+ string part = fix_path( p );
+
+ if ( path.size() == 0 ) {
+ path = part;
+ } else {
+ path += part;
+ }
+}
// destructor
~FGPath();
- // append to the existing path
+ // set path
+ void set( const string p );
+
+ // append another piece to the existing path
void append( const string p );
+ // concatenate a string to the end of the path without inserting a
+ // path separator
+ void concat( const string p );
+
// get the path string
- inline string get_path() const { return path; }
- inline const char *get_path_c_str() { return path.c_str(); }
+ inline string str() const { return path; }
+ inline const char *c_str() { return path.c_str(); }
};
#include "moon.hxx"
#include <Debug/logstream.hxx>
-#include <Objects/texload.h>
#include <Main/options.hxx>
+#include <Misc/fgpath.hxx>
+#include <Objects/texload.h>
#ifdef __BORLANDC__
# define exception c_exception
0.054900, 0.000000,
115.3654, 13.0649929509, t)
{
- string tpath, fg_tpath;
int width, height;
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// load in the texture data
- tpath = current_options.get_fg_root() + "/Textures/" + "moon.rgb";
-
+ FGPath tpath( current_options.get_fg_root() );
+ tpath.append( "Textures" );
+ tpath.append( "moon.rgb" );
+
if ( (moon_texbuf = read_rgb_texture(tpath.c_str(), &width, &height))
== NULL )
{
// Try compressed
- fg_tpath = tpath + ".gz";
+ FGPath fg_tpath = tpath;
+ fg_tpath.append( ".gz" );
if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height))
== NULL )
{
FG_LOG( FG_GENERAL, FG_ALERT,
- "Error in loading moon texture " << tpath );
+ "Error in loading moon texture " << tpath.str() );
exit(-1);
}
}
#include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx>
#include <Include/fg_constants.h>
+#include <Misc/fgpath.hxx>
#include <Misc/fgstream.hxx>
+#include <Misc/stopwatch.hxx>
#include <Main/options.hxx>
#include <Main/views.hxx>
-#include <Misc/stopwatch.hxx>
#include <Time/fg_time.hxx>
#include "Misc/stopwatch.hxx"
// Initialize the Star Management Subsystem
int fgStarsInit( void ) {
- Point3D starlist[FG_MAX_STARS];
+ // -dw- avoid local data > 32k error by dynamic allocation of the
+ // array, problem for some compilers
+ Point3D *starlist = new Point3D[FG_MAX_STARS];
// struct CelestialCoord pltPos;
double right_ascension, declination, magnitude;
double min_magnitude[FG_STAR_LEVELS];
}
// build the full path name to the stars data base file
- string path = current_options.get_fg_root() + "/Astro/stars" + ".gz";
-
- FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << path );
+ FGPath path ( current_options.get_fg_root() );
+ path.append( "Astro/stars" );
+ FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << path.str() );
- fg_gzifstream in( path );
+ fg_gzifstream in( path.str() );
if ( ! in ) {
- FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path );
+ FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path.str() );
exit(-1);
}
cockpit.cxx cockpit.hxx \
hud.cxx hud.hxx \
hud_card.cxx hud_dnst.cxx hud_guag.cxx hud_inst.cxx \
- hud_labl.cxx hud_ladr.cxx hud_scal.cxx hud_tbi.cxx \
+ hud_labl.cxx hud_ladr.cxx \
+ hud_scal.cxx hud_tbi.cxx \
panel.cxx panel.hxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
#include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx>
+#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Include/general.hxx>
#include <Main/options.hxx>
#include <Math/mat3.h>
#include <Math/polar3d.hxx>
#include <Scenery/scenery.hxx>
+#include <Time/fg_time.hxx>
#include <Time/fg_timer.hxx>
#include "cockpit.hxx"
double get_latitude( void )
{
- return((double)((int)( current_aircraft.fdm_state->get_Latitude()
- * RAD_TO_DEG)) );
+ return (double)((int)(current_aircraft.fdm_state->get_Latitude()*RAD_TO_DEG));
}
double get_lat_min( void )
return( (a - d) * 60.0);
}
+char*
+get_formated_gmt_time( void )
+{
+ static char buf[32];
+ FGTime *t = FGTime::cur_time_params;
+ const struct tm *p = t->getGmt();
+ sprintf( buf, "%d/%d/%2d %d:%02d:%02d",
+ p->tm_mon+1, p->tm_mday, p->tm_year,
+ p->tm_hour, p->tm_min, p->tm_sec);
+ return buf;
+}
+
+
double get_throttleval( void )
{
return controls.get_throttle( 0 ); // Hack limiting to one engine
#endif
#include <deque> // STL double ended queue
+#include <vector> // STL vector
#include <fg_typedefs.h>
#include <fg_constants.h>
#include <Controls/controls.hxx>
FG_USING_STD(deque);
+FG_USING_STD(vector);
#ifndef WIN32
typedef struct {
#include <Aircraft/aircraft.hxx>
#include <Main/options.hxx>
#include <Main/views.hxx>
+#include <Misc/fgpath.hxx>
#include <Objects/texload.h>
#include "panel.hxx"
// FGPanel::FGPanel() - constructor to initialize the panel.
FGPanel::FGPanel(void){
-
- string tpath;
int x, y;
FILE *f;
char line[256];
GLint test;
- GLubyte tex[262144];
+ GLubyte *tex = new GLubyte[262144];
OurPanel = this;
// load in the texture data
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 256);
- tpath = current_options.get_fg_root() + "/Textures/gauges.rgb";
+ FGPath tpath( current_options.get_fg_root() );
+ tpath.append( "Textures/gauges.rgb" );
if((img = read_rgb_texture( (char *)tpath.c_str(), &img_width, &img_height ))==NULL){
}
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 256);
- tpath = current_options.get_fg_root() + "/Textures/gauges2.rgb";
+ tpath.set( current_options.get_fg_root() );
+ tpath.append( "Textures/gauges2.rgb" );
if((imag = read_rgb_texture( (char *)tpath.c_str(), &imag_width, &imag_height ))==NULL){
}
xglPixelStorei(GL_UNPACK_ROW_LENGTH, 1024);
- tpath = current_options.get_fg_root() + "/Textures/Fullone.rgb";
+ tpath.set( current_options.get_fg_root() );
+ tpath.append( "Textures/Fullone.rgb" );
if ((background = read_rgb_texture( (char *)tpath.c_str(), &width, &height ))==NULL ){
}
xglDrawPixels(finx - x, finy - y, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)(background));
// restore original buffer state
- xglDrawBuffer( buffer );
+ xglDrawBuffer( (GLenum)buffer );
xglEnable(GL_DEPTH_TEST);
}
#include <Include/fg_constants.h>
#include <Main/options.hxx>
#include <Math/fg_geodesy.hxx>
+#include <Misc/fgpath.hxx>
#include <FDM/JSBsim/FGFDMExec.h>
#include <FDM/JSBsim/FGAircraft.h>
FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" );
- string aircraft_path = current_options.get_fg_root() + "/Aircraft";
- string engine_path = current_options.get_fg_root() + "/Engine";
+ FGPath aircraft_path( current_options.get_fg_root() );
+ aircraft_path.append( "Aircraft" );
- FDMExec.GetAircraft()->LoadAircraft(aircraft_path, engine_path, "X15");
+ FGPath engine_path( current_options.get_fg_root() );
+ engine_path.append( "Engine" );
+
+ FDMExec.GetAircraft()->LoadAircraft(aircraft_path.str(),
+ engine_path.str(), "X15");
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" );
- FDMExec.GetState()->Reset(aircraft_path, "Reset00");
+ FDMExec.GetState()->Reset(aircraft_path.str(), "Reset00");
FG_LOG( FG_FLIGHT, FG_INFO, " loaded initial conditions" );
FDMExec.GetState()->Setdt(dt);
#include "ls_types.h"
#include "ls_constants.h"
+#include "ls_geodesy.h"
#include "ls_generic.h"
#include "ls_sim_control.h"
#include "ls_cockpit.h"
/* Flight Gear Modification Log
*
* $Log$
- * Revision 1.1 1999/04/05 21:32:45 curt
- * Initial revision
+ * Revision 1.2 1999/04/27 19:28:04 curt
+ * Changes for the MacOS port contributed by Darrell Walisser.
+ *
+ * Revision 1.1.1.1 1999/04/05 21:32:45 curt
+ * Start of 0.6.x branch.
*
* Revision 1.25 1999/01/19 20:57:02 curt
* MacOS portability changes contributed by "Robert Puyol" <puyol@abvent.fr>
// Extrapolate fdm based on time_offset (in usec)
void FGInterface::extrapolate( int time_offset ) {
double dt = time_offset / 1000000.0;
+
+ // -dw- metrowerks complains about ambiguous access, not critical
+ // to keep this ;)
+#ifndef __MWERKS__
cout << "extrapolating FDM by dt = " << dt << endl;
+#endif
double lat = geodetic_position_v[0] + geocentric_rates_v[0] * dt;
double lat_geoc = geocentric_position_v[0] + geocentric_rates_v[0] * dt;
if ( model == FGInterface::FG_SLEW ) {
// fgSlewInit(dt);
+#ifndef __MWERKS__ // -dw- 04/22/99 JSB sim not ported yet
} else if ( model == FGInterface::FG_JSBSIM ) {
fgJSBsimInit(dt);
fgJSBsim_2_FGInterface(base_fdm_state);
+#endif
} else if ( model == FGInterface::FG_LARCSIM ) {
// lets try to avoid really screwing up the LaRCsim model
if ( base_fdm_state.get_Altitude() < -9000.0 ) {
if ( model == FGInterface::FG_SLEW ) {
// fgSlewUpdate(f, multiloop);
+#ifndef __MWERKS__ // -dw- 04/22/99 JSB sim not ported yet
} else if ( model == FGInterface::FG_JSBSIM ) {
fgJSBsimUpdate(base_fdm_state, multiloop);
f = base_fdm_state;
+#endif
} else if ( model == FGInterface::FG_LARCSIM ) {
fgLaRCsimUpdate(base_fdm_state, multiloop);
// extrapolate position based on actual time
#include <Math/mat3.h>
#include <Math/polar3d.hxx>
#include <Math/fg_random.h>
+#include <Misc/fgpath.hxx>
#include <plib/pu.h>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include "fg_serial.hxx"
+// -dw- use custom sioux settings so I can see output window
+#ifdef MACOS
+# ifndef FG_NDEBUG
+# include <sioux.h> // settings for output window
+# endif
+#endif
+
+
// This is a record containing a bit of global housekeeping information
FGGeneral general;
l = &cur_light_params;
+#ifndef GLUT_WRONG_VERSION
// Go full screen if requested ...
if ( current_options.get_fullscreen() ) {
glutFullScreen();
}
+#endif
// If enabled, normal vectors specified with glNormal are scaled
// to unit length after transformation. See glNormal.
}
}
+#if ! defined( MACOS )
// Do any serial port work that might need to be done
fgSerialProcess();
+#endif
// see if we need to load any new scenery tiles
fgTileMgrUpdate();
#if !defined(WIN32)
if ( current_options.get_intro_music() ) {
string lockfile = "/tmp/mpg123.running";
- string mp3file = current_options.get_fg_root() +
- "/Sounds/intro.mp3";
- string command = "(touch " + lockfile + "; mpg123 " + mp3file +
- "> /dev/null 2>&1; /bin/rm " + lockfile + ") &";
+ FGPath mp3file( current_options.get_fg_root() );
+ mp3file.append( "Sounds/intro.mp3" );
+
+ string command = "(touch " + lockfile + "; mpg123 "
+ + mp3file.str() + "> /dev/null 2>&1; /bin/rm "
+ + lockfile + ") &";
FG_LOG( FG_GENERAL, FG_INFO,
- "Starting intro music: " << mp3file );
+ "Starting intro music: " << mp3file.str() );
system ( command.c_str() );
}
#endif
audio_mixer = new smMixer;
audio_mixer -> setMasterVolume ( 80 ) ; /* 80% of max volume. */
audio_sched -> setSafetyMargin ( 1.0 ) ;
- string slfile = current_options.get_fg_root() + "/Sounds/wasp.wav";
+
+ FGPath slfile( current_options.get_fg_root() );
+ slfile.append( "Sounds/wasp.wav" );
s1 = new slSample ( (char *)slfile.c_str() );
FG_LOG( FG_GENERAL, FG_INFO,
if ( current_options.get_game_mode() == 0 ) {
// Open the regular window
xglutCreateWindow("Flight Gear");
+#ifndef GLUT_WRONG_VERSION
} else {
// Open the cool new 'game mode' window
char game_mode_str[256];
"game mode params = " << game_mode_str );
glutGameModeString( game_mode_str );
glutEnterGameMode();
+#endif
}
// This seems to be the absolute earliest in the init sequence
// Main ...
int main( int argc, char **argv ) {
+#ifdef MACOS
+# ifndef FG_NDEBUG
+
+ // -dw- this will not work unless called before any standard
+ // output, so why not put it here?
+ SIOUXSettings.toppixel = 540;
+ SIOUXSettings.leftpixel = 50;
+ SIOUXSettings.rows = 15;
+
+# endif
+#endif
+
FGInterface *f;
f = current_aircraft.fdm_state;
// Attempt to locate and parse a config file
// First check fg_root
- string config = current_options.get_fg_root() + "/system.fgfsrc";
- current_options.parse_config_file( config );
+ FGPath config( current_options.get_fg_root() );
+ config.append( "system.fgfsrc" );
+ current_options.parse_config_file( config.str() );
// Next check home directory
char* envp = ::getenv( "HOME" );
if ( envp != NULL ) {
- config = envp;
- config += "/.fgfsrc";
- current_options.parse_config_file( config );
+ config.set( envp );
+ config.append( ".fgfsrc" );
+ current_options.parse_config_file( config.str() );
}
// Parse remaining command line options
fgAPInit(¤t_aircraft);
// Initialize serial ports
+#if ! defined( MACOS )
fgSerialInit();
+#endif
FG_LOG( FG_GENERAL, FG_INFO, endl);
inline double
atof( const string& str )
{
+
+#ifdef __MWERKS__
+ // -dw- if ::atof is called, then we get an infinite loop
+ return std::atof( str.c_str() );
+#else
return ::atof( str.c_str() );
+#endif
}
inline int
atoi( const string& str )
{
+#ifdef __MWERKS__
+ // -dw- if ::atoi is called, then we get an infinite loop
+ return std::atoi( str.c_str() );
+#else
return ::atoi( str.c_str() );
+#endif
}
// Defined the shared options class here
// $FG_ROOT is not set. This can still be overridden from the
// command line or a config file.
-#if defined(WIN32)
+#if defined( WIN32 )
fg_root = "\\FlightGear";
+#elif defined( MACOS )
+ fg_root = ":";
#else
fg_root = "/usr/local/lib/FlightGear";
#endif
#include <Debug/logstream.hxx>
#include <Main/options.hxx>
#include <Math/fg_random.h>
+#include <Misc/fgpath.hxx>
#include <Objects/texload.h>
#include "splash.hxx"
// Initialize the splash screen
void fgSplashInit ( void ) {
- string tpath, fg_tpath;
int width, height;
FG_LOG( FG_GENERAL, FG_INFO, "Initializing splash screen" );
int num = (int)(fg_random() * 4.0 + 1.0);
char num_str[256];
sprintf(num_str, "%d", num);
- tpath = current_options.get_fg_root() + "/Textures/Splash";
- tpath += num_str;
- tpath += ".rgb";
+
+ FGPath tpath( current_options.get_fg_root() );
+ tpath.append( "Textures/Splash" );
+ tpath.concat( num_str );
+ tpath.concat( ".rgb" );
if ( (splash_texbuf =
read_rgb_texture(tpath.c_str(), &width, &height)) == NULL )
{
// Try compressed
- fg_tpath = tpath + ".gz";
+ FGPath fg_tpath = tpath;
+ fg_tpath.concat( ".gz" );
if ( (splash_texbuf =
read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL )
{
FG_LOG( FG_GENERAL, FG_ALERT,
- "Error in loading splash screen texture " << tpath );
+ "Error in loading splash screen texture " << tpath.str() );
exit(-1);
}
}
// #include <Bucket/bucketutils.hxx>
#include <Main/options.hxx>
#include <Main/views.hxx>
+#include <Misc/fgpath.hxx>
#include <Objects/obj.hxx>
#include "tile.hxx"
fgTILECACHE::fill_in( int index, FGBucket& p )
{
// Load the appropriate data file and build tile fragment list
- string tile_path = current_options.get_fg_root() +
- "/Scenery/" + p.gen_base_path() + "/" + p.gen_index_str();
+ FGPath tile_path( current_options.get_fg_root() );
+ tile_path.append( "Scenery" );
+ tile_path.append( p.gen_base_path() );
+ tile_path.append( p.gen_index_str() );
tile_cache[index].used = true;
tile_cache[index].tile_bucket = p;
- fgObjLoad( tile_path, &tile_cache[index] );
+ fgObjLoad( tile_path.str(), &tile_cache[index] );
// tile_cache[ index ].ObjLoad( tile_path, p );
// cout << " ncount before = " << tile_cache[index].ncount << "\n";
// cout << " fragments before = " << tile_cache[index].fragment_list.size()
// << "\n";
- string apt_path = tile_path + ".apt";
+ string apt_path = tile_path.str() + ".apt";
fgAptGenerate( apt_path, &tile_cache[index] );
// cout << " ncount after = " << tile_cache[index].ncount << "\n";
#include <Math/interpolater.hxx>
#include <Math/mat3.h>
#include <Math/polar3d.hxx>
+#include <Misc/fgpath.hxx>
#include "fg_time.hxx"
#include "light.hxx"
"Initializing Lighting interpolation tables." );
// build the path name to the ambient lookup table
- string path = current_options.get_fg_root();
- string ambient = path + "/Lighting/ambient";
- string diffuse = path + "/Lighting/diffuse";
- string sky = path + "/Lighting/sky";
+ FGPath path( current_options.get_fg_root() );
+ FGPath ambient = path;
+ ambient.append( "Lighting/ambient" );
+ FGPath diffuse = path;
+ diffuse.append( "Lighting/diffuse" );
+ FGPath sky = path;
+ sky.append( "Lighting/sky" );
// initialize ambient table
- ambient_tbl = new fgINTERPTABLE( ambient );
+ ambient_tbl = new fgINTERPTABLE( ambient.str() );
// initialize diffuse table
- diffuse_tbl = new fgINTERPTABLE( diffuse );
+ diffuse_tbl = new fgINTERPTABLE( diffuse.str() );
// initialize sky table
- sky_tbl = new fgINTERPTABLE( sky );
+ sky_tbl = new fgINTERPTABLE( sky.str() );
}
ftime(¤t);
seconds = current.time;
usec = current.millitm * 1000;
+#elif defined( __MWERKS__ )
+ // -dw- uses system clock to get time stamp... don't know if this works
+ long ticks = clock();
+ seconds = ticks / CLOCKS_PER_SEC;
+ usec = seconds * 100000;
#else
# error Port me
#endif