1
0
Fork 0

Reorganization of main.cxx

This commit is contained in:
ehofman 2003-08-17 09:54:41 +00:00
parent 830ce9108c
commit 5ae096b225
8 changed files with 223 additions and 200 deletions

View file

@ -23,6 +23,7 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/sky/sky.hxx>
#include <Main/main.hxx>
#include <Main/fg_props.hxx>
#include <Aircraft/aircraft.hxx>
@ -30,8 +31,6 @@
#include "environment_ctrl.hxx"
#include "environment_mgr.hxx"
extern SGSky *thesky; // FIXME: from main.cxx
FGEnvironmentMgr::FGEnvironmentMgr ()
: _environment(new FGEnvironment),

View file

@ -42,6 +42,7 @@
#include <plib/pu.h>
#include <Include/general.hxx>
#include <Main/main.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
@ -51,10 +52,6 @@
#include "preset_dlg.hxx"
// main.cxx hack, should come from an include someplace
extern void fgInitVisuals( void );
extern void fgRenderFrame( void );
extern void initDialog (void);
extern void mkDialogInit (void);
extern void ConfirmExitDialogInit(void);

View file

@ -73,6 +73,7 @@
#include <Cockpit/panel.hxx>
#include <Controls/controls.hxx>
#include <FDM/flight.hxx>
#include <Main/main.hxx>
#include <Main/fg_init.hxx>
#include <Main/fg_io.hxx>
#include <Main/globals.hxx>
@ -98,10 +99,6 @@
SG_USING_STD(string);
SG_USING_STD(cout);
// main.cxx hack, should come from an include someplace
extern void fgInitVisuals( void );
extern void fgRenderFrame( void );
extern void fgHUDalphaAdjust( puObject * );
// from cockpit.cxx

View file

@ -16,7 +16,6 @@ else
NETWORK_LIBS =
endif
if WITH_THREADS
THREAD_LIBS = -lsgthreads $(thread_LIBS)
else
@ -45,10 +44,12 @@ bin_PROGRAMS = fgfs
noinst_SCRIPTS = runfgfs.bat runfgfs
noinst_LIBRARIES = libMain.a
# bin_SCRIPTS = runfgfs
fgfs_SOURCES = \
main.cxx \
libMain_a_SOURCES = \
main.cxx main.hxx \
fg_commands.cxx fg_commands.hxx \
fg_init.cxx fg_init.hxx \
fg_io.cxx fg_io.hxx \
@ -62,7 +63,10 @@ fgfs_SOURCES = \
viewer.cxx viewer.hxx \
viewmgr.cxx viewmgr.hxx
fgfs_SOURCES = bootstrap.cxx
fgfs_LDADD = \
$(top_builddir)/src/Main/libMain.a \
$(top_builddir)/src/Aircraft/libAircraft.a \
$(top_builddir)/src/ATC/libATC.a \
$(top_builddir)/src/Autopilot/libAutopilot.a \

151
src/Main/bootstrap.cxx Normal file
View file

@ -0,0 +1,151 @@
// bootstrap.cxx -- bootstrap routines: main()
//
// Written by Curtis Olson, started May 1997.
//
// Copyright (C) 1997 - 2002 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if defined(__linux__) && defined(__i386__)
# include <fpu_control.h>
# include <signal.h>
#endif
#include <stdlib.h>
#include <simgear/compiler.h>
#include <simgear/misc/exception.hxx>
#include STL_IOSTREAM
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include "main.hxx"
#ifdef HAVE_WINDOWS_H
# include <windows.h>
# include <float.h>
#endif
#include GLUT_H
#ifdef macintosh
# include <console.h> // -dw- for command line dialog
#endif
#if defined(__linux__) && defined(__i386__)
static void handleFPE (int);
static void
initFPE ()
{
fpu_control_t fpe_flags = 0;
_FPU_GETCW(fpe_flags);
// fpe_flags &= ~_FPU_MASK_IM; // invalid operation
// fpe_flags &= ~_FPU_MASK_DM; // denormalized operand
// fpe_flags &= ~_FPU_MASK_ZM; // zero-divide
// fpe_flags &= ~_FPU_MASK_OM; // overflow
// fpe_flags &= ~_FPU_MASK_UM; // underflow
// fpe_flags &= ~_FPU_MASK_PM; // precision (inexact result)
_FPU_SETCW(fpe_flags);
signal(SIGFPE, handleFPE);
}
static void
handleFPE (int num)
{
initFPE();
SG_LOG(SG_GENERAL, SG_ALERT, "Floating point interrupt (SIGFPE)");
}
#endif
#ifdef __APPLE__
typedef struct
{
int lo;
int hi;
} PSN;
extern "C" {
short CPSGetCurrentProcess(PSN *psn);
short CPSSetProcessName (PSN *psn, char *processname);
short CPSEnableForegroundOperation(PSN *psn, int _arg2, int _arg3, int _arg4, int _arg5);
short CPSSetFrontProcess(PSN *psn);
};
#define CPSEnableFG(psn) CPSEnableForegroundOperation(psn,0x03,0x3C,0x2C,0x1103)
#endif
// Main entry point; catch any exceptions that have made it this far.
int main ( int argc, char **argv ) {
// Enable floating-point exceptions for Linux/x86
#if defined(__linux__) && defined(__i386__)
initFPE();
#endif
// Enable floating-point exceptions for Windows
#if defined( _MSC_VER ) && defined( DEBUG )
// Christian, we should document what this does
_control87( _EM_INEXACT, _MCW_EM );
#endif
#if defined( HAVE_BC5PLUS )
_control87(MCW_EM, MCW_EM); /* defined in float.h */
#endif
// Keyboard focus hack
#ifdef __APPLE__
{
PSN psn;
glutInit (&argc, argv);
CPSGetCurrentProcess(&psn);
CPSSetProcessName(&psn, "FlightGear");
CPSEnableFG(&psn);
CPSSetFrontProcess(&psn);
}
#endif
// FIXME: add other, more specific
// exceptions.
try {
fgMainInit(argc, argv);
} catch (sg_throwable &t) {
// We must use cerr rather than
// logging, since logging may be
// disabled.
cerr << "Fatal error: " << t.getFormattedMessage()
<< "\n (received from " << t.getOrigin() << ')' << endl;
exit(1);
}
return 0;
}

View file

@ -25,24 +25,13 @@
# include <config.h>
#endif
#include <simgear/compiler.h>
#if defined(__linux__) && defined(__i386__)
# include <fpu_control.h>
# include <signal.h>
#endif
#include <simgear/compiler.h>
#include STL_IOSTREAM
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include <simgear/misc/exception.hxx>
#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/route/route.hxx>
#include <simgear/screen/extensions.hxx>
#include <Environment/environment_mgr.hxx>
#ifdef SG_MATH_EXCEPTION_CLASH
# include <math.h>
#endif
@ -52,65 +41,53 @@ SG_USING_STD(endl);
# include <float.h>
#endif
#include GLUT_H
#include <stdio.h>
#include <string.h> // for strcmp()
#include <string>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h> // for stat()
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for stat()
#endif
#include <plib/netChat.h>
#include <plib/pu.h>
#include <plib/sg.h>
#include <plib/ssg.h>
#include <plib/pu.h>
#include <simgear/constants.h> // for VERSION
#include <simgear/debug/logstream.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/misc/sg_path.hxx>
#include <simgear/screen/extensions.hxx>
#include <simgear/scene/material/matlib.hxx>
#include <simgear/props/props.hxx>
#include <simgear/scene/sky/sky.hxx>
#include <simgear/timing/sg_time.hxx>
#include <simgear/scene/model/animation.hxx>
#include <simgear/scene/model/location.hxx>
#include <simgear/scene/model/model.hxx>
#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/scene/model/placement.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/route/route.hxx>
#include <simgear/scene/model/modellib.hxx>
#ifdef FG_USE_CLOUDS_3D
# include <simgear/scene/sky/clouds3d/SkySceneLoader.hpp>
# include <simgear/scene/sky/clouds3d/SkyUtil.hpp>
#endif
#include <simgear/scene/sky/sky.hxx>
#include <simgear/timing/sg_time.hxx>
#include <Include/general.hxx>
#include <Scenery/tileentry.hxx>
#include <Time/FGEventMgr.hxx>
#include <Time/light.hxx>
#include <Time/light.hxx>
#include <Aircraft/aircraft.hxx>
#include <ATC/ATCmgr.hxx>
#include <ATC/ATCdisplay.hxx>
#include <ATC/AIMgr.hxx>
#include <Autopilot/newauto.hxx>
#include <Cockpit/hud.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/cockpit.hxx>
#include <Cockpit/radiostack.hxx>
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
#include <GUI/gui.h>
#include <Model/acmodel.hxx>
#include <Model/modelmgr.hxx>
#include <Cockpit/hud.hxx>
#include <Model/panelnode.hxx>
#include <Model/modelmgr.hxx>
#include <Model/acmodel.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <FDM/flight.hxx>
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
#include <FDM/ADA.hxx>
#include <ATC/ATCdisplay.hxx>
#include <ATC/ATCmgr.hxx>
#include <ATC/AIMgr.hxx>
#include <Autopilot/newauto.hxx>
#include <Replay/replay.hxx>
#include <Time/tmp.hxx>
#include <Time/fg_timer.hxx>
#include <Environment/environment_mgr.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
#endif
@ -120,29 +97,10 @@ SG_USING_STD(endl);
#include <MultiPlayer/multiplayrxmgr.hxx>
#endif
#include <Replay/replay.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#ifdef ENABLE_AUDIO_SUPPORT
# include <Sound/fg_fx.hxx>
# include <Sound/morse.hxx>
#endif
#include <Systems/system_mgr.hxx>
#include <Instrumentation/instrument_mgr.hxx>
#include <Time/FGEventMgr.hxx>
#include <Time/fg_timer.hxx>
#include <Time/light.hxx>
#include <Time/sunpos.hxx>
#include <Time/tmp.hxx>
// ADA
#include <simgear/misc/sgstream.hxx>
#include <simgear/math/point3d.hxx>
#include <FDM/flight.hxx>
#include <FDM/ADA.hxx>
#include <Scenery/tileentry.hxx>
#include "splash.hxx"
#include "fg_commands.hxx"
#include "fg_io.hxx"
glPointParameterfProc glPointParameterfPtr = 0;
glPointParameterfvProc glPointParameterfvPtr = 0;
@ -173,22 +131,10 @@ static double delta_time_sec = 0.0;
# include <WeatherCM/FGLocalWeatherDatabase.h>
#endif
#include "version.h"
#include "fg_init.hxx"
#include "fg_io.hxx"
#include "fg_props.hxx"
#include "globals.hxx"
#include "splash.hxx"
#include "viewmgr.hxx"
#include "options.hxx"
#include "logger.hxx"
#ifdef macintosh
# include <console.h> // -dw- for command line dialog
#endif
FGEventMgr global_events;
// This is a record containing a bit of global housekeeping information
@ -1592,7 +1538,7 @@ static bool fgGlutInitEvents( void ) {
}
// Main top level initialization
static bool fgMainInit( int argc, char **argv ) {
bool fgMainInit( int argc, char **argv ) {
#if defined( macintosh )
freopen ("stdout.txt", "w", stdout );
@ -1859,100 +1805,6 @@ static bool fgMainInit( int argc, char **argv ) {
// $$$ end - added VS Renganathan, 15 Oct 2K
// - added Venky , 12 Nov 2K
#if defined(__linux__) && defined(__i386__)
static void handleFPE (int);
static void
initFPE ()
{
fpu_control_t fpe_flags = 0;
_FPU_GETCW(fpe_flags);
// fpe_flags &= ~_FPU_MASK_IM; // invalid operation
// fpe_flags &= ~_FPU_MASK_DM; // denormalized operand
// fpe_flags &= ~_FPU_MASK_ZM; // zero-divide
// fpe_flags &= ~_FPU_MASK_OM; // overflow
// fpe_flags &= ~_FPU_MASK_UM; // underflow
// fpe_flags &= ~_FPU_MASK_PM; // precision (inexact result)
_FPU_SETCW(fpe_flags);
signal(SIGFPE, handleFPE);
}
static void
handleFPE (int num)
{
initFPE();
SG_LOG(SG_GENERAL, SG_ALERT, "Floating point interrupt (SIGFPE)");
}
#endif
#ifdef __APPLE__
typedef struct
{
int lo;
int hi;
} PSN;
extern "C" {
short CPSGetCurrentProcess(PSN *psn);
short CPSSetProcessName (PSN *psn, char *processname);
short CPSEnableForegroundOperation(PSN *psn, int _arg2, int _arg3, int _arg4, int _arg5);
short CPSSetFrontProcess(PSN *psn);
};
#define CPSEnableFG(psn) CPSEnableForegroundOperation(psn,0x03,0x3C,0x2C,0x1103)
#endif
// Main entry point; catch any exceptions that have made it this far.
int main ( int argc, char **argv ) {
// Enable floating-point exceptions for Linux/x86
#if defined(__linux__) && defined(__i386__)
initFPE();
#endif
// Enable floating-point exceptions for Windows
#if defined( _MSC_VER ) && defined( DEBUG )
// Christian, we should document what this does
_control87( _EM_INEXACT, _MCW_EM );
#endif
#if defined( HAVE_BC5PLUS )
_control87(MCW_EM, MCW_EM); /* defined in float.h */
#endif
// Keyboard focus hack
#ifdef __APPLE__
{
PSN psn;
glutInit (&argc, argv);
CPSGetCurrentProcess(&psn);
CPSSetProcessName(&psn, "FlightGear");
CPSEnableFG(&psn);
CPSSetFrontProcess(&psn);
}
#endif
// FIXME: add other, more specific
// exceptions.
try {
fgMainInit(argc, argv);
} catch (sg_throwable &t) {
// We must use cerr rather than
// logging, since logging may be
// disabled.
cerr << "Fatal error: " << t.getFormattedMessage()
<< "\n (received from " << t.getOrigin() << ')' << endl;
exit(1);
}
return 0;
}
void fgLoadDCS(void) {

23
src/Main/main.hxx Normal file
View file

@ -0,0 +1,23 @@
#ifndef __FG_MAIN_HXX
#define __FG_MAIN_HXX 1
class SGSky;
extern SGSky *thesky;
void fgLoadDCS (void);
void fgUpdateDCS (void);
void fgBuildRenderStates( void );
void fgInitVisuals( void );
void fgRenderFrame();
void fgUpdateTimeDepCalcs();
void fgInitTimeDepCalcs( void );
void fgReshape( int width, int height );
void fgLoadDCS(void);
void fgUpdateDCS (void);
bool fgMainInit( int argc, char **argv );
#endif

View file

@ -55,6 +55,7 @@ SG_USING_STD(string);
#include <simgear/scene/sky/sky.hxx>
#include <simgear/screen/colors.hxx>
#include <Main/main.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/viewer.hxx>
@ -62,7 +63,6 @@ SG_USING_STD(string);
#include "light.hxx"
#include "sunpos.hxx"
extern SGSky *thesky; // FIXME: from main.cxx
fgLIGHT cur_light_params;