From: curt Date: Mon, 16 Nov 1998 13:59:58 +0000 (+0000) Subject: Added pow() macro bug work around. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f2234416b011548d313b5a39d3cd1100b49e1623;p=flightgear.git Added pow() macro bug work around. Added support for starting FGFS at various resolutions. Added some initial serial port support. Specify default log levels in main(). --- diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx index 562753a99..f671e3328 100644 --- a/Main/GLUTmain.cxx +++ b/Main/GLUTmain.cxx @@ -178,7 +178,7 @@ static void fgInitVisuals( void ) { } -#ifdef IS_THIS_BETTER_THAN_A_ZERO_CHARLIE +#if 0 // Draw a basic instrument panel static void fgUpdateInstrViewParams( void ) { @@ -562,7 +562,8 @@ static void fgMainLoop( void ) { FG_Runway_altitude * FEET_TO_METER, FG_Altitude * FEET_TO_METER); */ - // fgAircraftOutputCurrent(a); + // Do any serial port work that might need to be done + fgSerialProcess(); // see if we need to load any new scenery tiles fgTileMgrUpdate(); @@ -606,7 +607,8 @@ static void fgMainLoop( void ) { // need to calculate some reasonable scaling factor and // then clamp it on the positive aoa (neg adj) side double aoa = FG_Gamma_vert_rad * 2.2; - double aoa_adj = pow(-aoa, 3) * pow(M_E, aoa); + double tmp = 3.0; + double aoa_adj = pow(-aoa, tmp) * pow(M_E, aoa); if (aoa_adj < -0.8) aoa_adj = -0.8; pitch += aoa_adj; //fprintf(stderr, "pitch3: %f ", pitch); @@ -831,8 +833,12 @@ int fgGlutInit( int *argc, char **argv ) { // Define Display Parameters xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); + FG_LOG( FG_GENERAL, FG_INFO, "Opening a window: " << + current_options.get_xsize() << "x" << current_options.get_ysize() ); + // Define initial window size - xglutInitWindowSize(640, 480); + xglutInitWindowSize( current_options.get_xsize(), + current_options.get_ysize() ); // Initialize windows if ( current_options.get_game_mode() == 0 ) { @@ -840,7 +846,11 @@ int fgGlutInit( int *argc, char **argv ) { xglutCreateWindow("Flight Gear"); } else { // Open the cool new 'game mode' window - glutGameModeString("width=640 height=480 bpp=16"); + string game_mode_params = "width=" + current_options.get_xsize(); + game_mode_params += "height=" + current_options.get_ysize(); + game_mode_params += " bpp=16"; + cout << "game mode params = " << game_mode_params; + glutGameModeString( game_mode_params.c_str() ); glutEnterGameMode(); } @@ -886,6 +896,9 @@ int main( int argc, char **argv ) { // Initialize the [old] debugging output system // fgInitDebug(); + // set default log levels + fglog().setLogLevels( FG_ALL, FG_INFO ); + FG_LOG( FG_GENERAL, FG_INFO, "Flight Gear: Version" << VERSION << endl ); // Attempt to locate and parse a config file @@ -909,7 +922,8 @@ int main( int argc, char **argv ) { // Something must have gone horribly wrong with the command // line parsing or maybe the user just requested help ... :-) current_options.usage(); - FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ..."); + // FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ..."); + cout << endl << "Exiting ..." << endl; exit(-1); } @@ -946,6 +960,12 @@ int main( int argc, char **argv ) { // $Log$ +// Revision 1.67 1998/11/16 13:59:58 curt +// Added pow() macro bug work around. +// Added support for starting FGFS at various resolutions. +// Added some initial serial port support. +// Specify default log levels in main(). +// // Revision 1.66 1998/11/11 00:24:00 curt // Added Michael Johnson's audio patches for testing. // Also did a few tweaks to avoid numerical problems when starting at a place diff --git a/Main/Makefile.am b/Main/Makefile.am index 967de92b9..e16886e3d 100644 --- a/Main/Makefile.am +++ b/Main/Makefile.am @@ -23,6 +23,12 @@ if ENABLE_XMESA_FX DEFS += -DXMESA -DFX endif +if ENABLE_UNIX_SERIAL +SERIAL_LIBS = $(top_builddir)/Lib/Serial/libSerial.a +else +SERIAL_LIBS = +endif + EXTRA_DIST = runfgfs.in runfgfs.bat.in bin_PROGRAMS = fgfs @@ -33,6 +39,7 @@ fgfs_SOURCES = \ GLUTkey.cxx GLUTkey.hxx GLUTmain.cxx \ fg_config.h \ fg_init.cxx fg_init.hxx \ + fg_serial.cxx fg_serial.hxx \ options.cxx options.hxx \ splash.cxx splash.hxx \ views.cxx views.hxx @@ -53,7 +60,7 @@ fgfs_LDADD = \ $(top_builddir)/Simulator/Time/libTime.a \ $(top_builddir)/Simulator/Weather/libWeather.a \ $(top_builddir)/Simulator/Joystick/libJoystick.a \ - $(AUDIO_LIBS) \ + $(AUDIO_LIBS) $(SERIAL_LIBS) \ $(top_builddir)/Lib/Math/libMath.a \ $(top_builddir)/Lib/Bucket/libBucket.a \ $(top_builddir)/Lib/Debug/libDebug.a \ diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx index e9c090669..beed3c41f 100644 --- a/Main/fg_init.cxx +++ b/Main/fg_init.cxx @@ -129,9 +129,6 @@ int fgInitGeneral( void ) { g = &general; - // set default log levels - fglog().setLogLevels( FG_ALL, FG_INFO ); - FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" ); FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" ); @@ -373,7 +370,10 @@ int fgInitSubsystems( void ) // Autopilot init added here, by Jeff Goeke-Smith fgAPInit(¤t_aircraft); - + + // Initialize serial ports + fgSerialInit(); + FG_LOG( FG_GENERAL, FG_INFO, endl); return(1); @@ -381,6 +381,12 @@ int fgInitSubsystems( void ) // $Log$ +// Revision 1.50 1998/11/16 14:00:01 curt +// Added pow() macro bug work around. +// Added support for starting FGFS at various resolutions. +// Added some initial serial port support. +// Specify default log levels in main(). +// // Revision 1.49 1998/11/11 00:24:02 curt // Added Michael Johnson's audio patches for testing. // Also did a few tweaks to avoid numerical problems when starting at a place diff --git a/Main/options.cxx b/Main/options.cxx index 3d126fafc..69ffbc14e 100644 --- a/Main/options.cxx +++ b/Main/options.cxx @@ -38,11 +38,15 @@ #include #include +#include "fg_serial.hxx" + #include "options.hxx" + const int fgOPTIONS::FG_RADIUS_MIN; const int fgOPTIONS::FG_RADIUS_MAX; + inline double atof( const string& str ) { @@ -92,10 +96,6 @@ fgOPTIONS::fgOPTIONS() : // lon(-111.7884614 + 0.01), // lat( 34.8486289 - 0.015), - // Somewhere near the Grand Canyon - // lon(-112.5), - // lat( 36.5), - // Jim Brennon's Kingmont Observatory // lon(-121.1131667), // lat( 38.8293917), @@ -108,10 +108,6 @@ fgOPTIONS::fgOPTIONS() : // lon(-73.5), // lat( 10.0), - // Test Position - // lon( 8.5), - // lat(47.5), - // Timms Hill (WI) // lon(-90.1953055556), // lat( 45.4511388889), @@ -148,6 +144,8 @@ fgOPTIONS::fgOPTIONS() : skyblend(1), textures(1), wireframe(0), + xsize(640), + ysize(480), // Scenery options tile_diameter(5), @@ -157,7 +155,19 @@ fgOPTIONS::fgOPTIONS() : tris_or_culled(0), // Time options - time_offset(0) + time_offset(0), + + // Serial port options + // port_a(FG_SERIAL_DISABLED), + // port_b(FG_SERIAL_DISABLED), + // port_c(FG_SERIAL_DISABLED), + // port_d(FG_SERIAL_DISABLED), + + port_a_config(""), + port_b_config(""), + port_c_config(""), + port_d_config("") + { // set initial values/defaults char* envp = ::getenv( "FG_ROOT" ); @@ -339,6 +349,53 @@ fgOPTIONS::parse_fov( const string& arg ) { } +// Parse serial port option --serial=a,/dev/ttyS1,nmea,4800,out +// +// Format is "--serial=port_id,device,format,baud,direction" where +// +// port_id = {a, b, c, d} +// device = OS device name to be open()'ed +// format = {nmea, fgfs} +// baud = {300, 1200, 2400, ..., 230400} +// direction = {in, out, bi} +// +bool +fgOPTIONS::parse_serial( const string& serial_str ) { + string::size_type pos; + string port; + string config; + + // cout << "Serial string = " << serial_str << endl; + + // port + pos = serial_str.find(","); + if ( pos == string::npos ) { + FG_LOG( FG_GENERAL, FG_ALERT, + "Malformed serial port configure string" ); + return false; + } + + port = serial_str.substr(0, pos); + config = serial_str.substr(++pos); + + if ( port == "a" ) { + port_a_config = config; + } else if ( port == "b" ) { + port_b_config = config; + } else if ( port == "c" ) { + port_c_config = config; + } else if ( port == "d" ) { + port_d_config = config; + } else { + FG_LOG( FG_GENERAL, FG_ALERT, "Valid ports are a - d, config for port " + << port << " ignored" ); + return false; + } + + return true; +} + + // Parse a single option int fgOPTIONS::parse_option( const string& arg ) { // General Options @@ -418,11 +475,26 @@ int fgOPTIONS::parse_option( const string& arg ) { } else if ( arg == "--disable-textures" ) { textures = false; } else if ( arg == "--enable-textures" ) { - textures = true; + textures = true; } else if ( arg == "--disable-wireframe" ) { wireframe = false; } else if ( arg == "--enable-wireframe" ) { - wireframe = true; + wireframe = true; + } else if ( arg.find( "--geometry=" ) != string::npos ) { + string geometry = arg.substr( 11 ); + if ( geometry == "640x480" ) { + xsize = 640; + ysize = 480; + } else if ( geometry == "800x600" ) { + xsize = 800; + ysize = 600; + } else if ( geometry == "1024x768" ) { + xsize = 1024; + ysize = 768; + } else { + FG_LOG( FG_GENERAL, FG_ALERT, "Unknown geometry: " << geometry ); + exit(-1); + } } else if ( arg == "--units-feet" ) { units = FG_UNITS_FEET; } else if ( arg == "--units-meters" ) { @@ -435,7 +507,9 @@ int fgOPTIONS::parse_option( const string& arg ) { } else if ( arg == "--hud-tris" ) { tris_or_culled = 0; } else if ( arg == "--hud-culled" ) { - tris_or_culled = 1; + tris_or_culled = 1; + } else if ( arg.find( "--serial=" ) != string::npos ) { + parse_serial( arg.substr(9) ); } else { FG_LOG( FG_GENERAL, FG_ALERT, "Unknown option '" << arg << "'" ); return FG_OPTIONS_ERROR; @@ -549,6 +623,7 @@ void fgOPTIONS::usage ( void ) { printf("\t--enable-textures: enable textures\n"); printf("\t--disable-wireframe: disable wireframe drawing mode\n"); printf("\t--enable-wireframe: enable wireframe drawing mode\n"); + printf("\t--geomtry=WWWxHHH: specify window geometry: 640x480, 800x600\n"); printf("\n"); printf("Scenery Options:\n"); @@ -572,6 +647,12 @@ fgOPTIONS::~fgOPTIONS( void ) { // $Log$ +// Revision 1.30 1998/11/16 14:00:02 curt +// Added pow() macro bug work around. +// Added support for starting FGFS at various resolutions. +// Added some initial serial port support. +// Specify default log levels in main(). +// // Revision 1.29 1998/11/06 21:18:12 curt // Converted to new logstream debugging facility. This allows release // builds with no messages at all (and no performance impact) by using diff --git a/Main/options.hxx b/Main/options.hxx index 13840cbd9..5132759be 100644 --- a/Main/options.hxx +++ b/Main/options.hxx @@ -47,6 +47,8 @@ using namespace std; #endif +#include "fg_serial.hxx" + class fgOPTIONS { @@ -112,6 +114,7 @@ private: bool skyblend; // Blend sky to haze (using polygons) or just clear bool textures; // Textures enabled/disabled bool wireframe; // Wireframe mode enabled/disabled + int xsize, ysize; // window size derived from geometry string // Scenery options int tile_radius; // Square radius of rendered tiles (around center @@ -128,6 +131,18 @@ private: // Time options int time_offset; // Offset true time by this many seconds + // Serial Ports, we currently support up to four channels + // fgSerialPortKind port_a_kind; // Port a kind + // fgSerialPortKind port_b_kind; // Port b kind + // fgSerialPortKind port_c_kind; // Port c kind + // fgSerialPortKind port_d_kind; // Port d kind + + // Serial port configuration strings + string port_a_config; + string port_b_config; + string port_c_config; + string port_d_config; + public: fgOPTIONS(); @@ -171,12 +186,26 @@ public: inline bool get_skyblend() const { return skyblend; } inline bool get_textures() const { return textures; } inline bool get_wireframe() const { return wireframe; } + inline int get_xsize() const { return xsize; } + inline int get_ysize() const { return ysize; } inline int get_tile_radius() const { return tile_radius; } inline int get_tile_diameter() const { return tile_diameter; } - inline int get_time_offset() const { return time_offset; } + inline int get_units() const { return units; } inline int get_tris_or_culled() const { return tris_or_culled; } + inline int get_time_offset() const { return time_offset; } + + // inline fgSerialPortKind get_port_a_kind() const { return port_a_kind; } + // inline fgSerialPortKind get_port_b_kind() const { return port_b_kind; } + // inline fgSerialPortKind get_port_c_kind() const { return port_c_kind; } + // inline fgSerialPortKind get_port_d_kind() const { return port_d_kind; } + + inline string get_port_a_config() const { return port_a_config; } + inline string get_port_b_config() const { return port_b_config; } + inline string get_port_c_config() const { return port_c_config; } + inline string get_port_d_config() const { return port_d_config; } + // Update functions inline void set_hud_status( bool status ) { hud_status = status; } inline void set_fov( double amount ) { fov = amount; } @@ -201,6 +230,7 @@ private: int parse_tile_radius( const string& arg ); int parse_flight_model( const string& fm ); double parse_fov( const string& arg ); + bool parse_serial( const string& serial_str ); }; @@ -211,6 +241,12 @@ extern fgOPTIONS current_options; // $Log$ +// Revision 1.21 1998/11/16 14:00:04 curt +// Added pow() macro bug work around. +// Added support for starting FGFS at various resolutions. +// Added some initial serial port support. +// Specify default log levels in main(). +// // Revision 1.20 1998/11/02 23:04:05 curt // HUD units now display in feet by default with meters being a command line // option. diff --git a/Main/splash.cxx b/Main/splash.cxx index 9c87cd166..ceb40d225 100644 --- a/Main/splash.cxx +++ b/Main/splash.cxx @@ -41,6 +41,7 @@ #include #include "splash.hxx" +#include "views.hxx" static GLuint splash_texid; @@ -96,10 +97,10 @@ void fgSplashUpdate ( double progress ) { int xsize = 480; int ysize = 380; - xmin = (640 - xsize) / 2; + xmin = (current_view.winWidth - xsize) / 2; xmax = xmin + xsize; - ymin = (480 - ysize) / 2; + ymin = (current_view.winHeight - ysize) / 2; ymax = ymin + ysize; // first clear the screen; @@ -110,7 +111,7 @@ void fgSplashUpdate ( double progress ) { xglMatrixMode(GL_PROJECTION); xglPushMatrix(); xglLoadIdentity(); - gluOrtho2D(0, 640, 0, 480); + gluOrtho2D(0, current_view.winWidth, 0, current_view.winHeight); xglMatrixMode(GL_MODELVIEW); xglPushMatrix(); xglLoadIdentity(); @@ -148,6 +149,12 @@ void fgSplashUpdate ( double progress ) { // $Log$ +// Revision 1.8 1998/11/16 14:00:05 curt +// Added pow() macro bug work around. +// Added support for starting FGFS at various resolutions. +// Added some initial serial port support. +// Specify default log levels in main(). +// // Revision 1.7 1998/11/06 21:18:14 curt // Converted to new logstream debugging facility. This allows release // builds with no messages at all (and no performance impact) by using diff --git a/Main/views.cxx b/Main/views.cxx index 324cfff37..f9cc55104 100644 --- a/Main/views.cxx +++ b/Main/views.cxx @@ -58,8 +58,8 @@ void fgVIEW::Init( void ) { view_offset = 0.0; goal_view_offset = 0.0; - winWidth = 640; // FG_DEFAULT_WIN_WIDTH - winHeight = 480; // FG_DEFAULT_WIN_HEIGHT + winWidth = current_options.get_xsize(); + winHeight = current_options.get_ysize(); win_ratio = (double) winWidth / (double) winHeight; update_fov = true; } @@ -599,6 +599,12 @@ fgVIEW::~fgVIEW( void ) { // $Log$ +// Revision 1.27 1998/11/16 14:00:06 curt +// Added pow() macro bug work around. +// Added support for starting FGFS at various resolutions. +// Added some initial serial port support. +// Specify default log levels in main(). +// // Revision 1.26 1998/11/09 23:39:25 curt // Tweaks for the instrument panel. //